Compare commits

..

1 Commits
2.0.1 ... 0.9

Author SHA1 Message Date
Michael Kaufmann (d00p)
8d1e4889b3 tagging froxlor-0.9 2010-02-01 10:49:31 +00:00
1100 changed files with 61650 additions and 142747 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 +0,0 @@
# Contribution
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
General rules for PRs are:
* Please save us all some trouble and unnecessary round-trips by _testing_ your changes.
* 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...
Thanks!
### Service changes
If you make changes to the functionality of service configurations, please make sure your implementation covers all supported services and distributions.
### l10n
If you add new language strings, please make sure you add the english fallback strings in `lng/en.php`.
### New settings and database-layout changes
If you add new settings or implement database-changes, please make sure you add these to
* `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

4
.github/FUNDING.yml vendored
View File

@@ -1,4 +0,0 @@
# These are supported funding model platforms
github: d00p
custom: ['https://paypal.me/Froxlor']

View File

@@ -1,49 +0,0 @@
# Bug report vs. support request
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
* or post a thread in our forum at https://forum.froxlor.org
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
* try with the git master
# Summary
Please provide a concise summary of the problem you're experiencing...
# System information
* Froxlor version: $version/$gitSHA1
* Web server: apache2/nginx/lighttpd
* DNS server: Bind/PowerDNS (standalone)/PowerDNS (Bind-backend)
* POP/IMAP server: Courier/Dovecot
* SMTP server: postfix/exim
* FTP server: proftpd/pureftpd
* OS/Version: ...
# Steps to reproduce
1.
2.
3.
# Expected behavior
1.
2.
3.
# Actual behavior
1.
2.
3.
# Log files/log entries
syslog:
<pre>
example
</pre>

View File

@@ -1,40 +0,0 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**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
* try with the git master
**Describe the bug**
A clear and concise description of what the bug is.
**System information**
* Froxlor version: $version/$gitSHA1
* Web server: apache2/nginx/lighttpd
* DNS server: Bind/PowerDNS (standalone)/PowerDNS (Bind-backend)
* POP/IMAP server: Courier/Dovecot
* SMTP server: postfix/exim
* FTP server: proftpd/pureftpd
* OS/Version: ...
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Logfiles**
If applicable, add log-entries to help explain your problem.
**Additional context**
Add any other context about the problem here.

View File

@@ -1,20 +0,0 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

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

@@ -1,37 +0,0 @@
# Description
Please include a summary of the change and which issue is fixed if any. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes # (issue)
## Type of change
Please delete options that are not relevant.
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update
# How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
- [ ] Test A
- [ ] Test B
**Test Configuration**:
* Distribution:
* Webserver:
* PHP:
* etc.etc.:
# Checklist:
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] 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

View File

@@ -1,14 +0,0 @@
name: build-docs
on:
release:
types: [published]
jobs:
build_docs:
runs-on: ubuntu-latest
steps:
- env:
GITHUB_TOKEN: ${{ secrets.ORG_GITHUB_TOKEN }}
run: |
gh workflow run --repo Froxlor/Documentation build-docs -f ref=${{github.ref_name}}

View File

@@ -1,81 +0,0 @@
name: Froxlor-CI-MariaDB
on: ['push', 'pull_request', 'create']
jobs:
froxlor:
name: Froxlor (PHP ${{ matrix.php-versions }}, MariaDB ${{ matrix.mariadb-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: ['7.4', '8.1']
mariadb-version: [10.5, 10.4]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: composer:v2
extensions: mbstring, xml, ctype, pdo_mysql, mysql, curl, json, zip, session, filter, posix, openssl, fileinfo, bcmath, gmp
- name: Install tools
run: sudo apt-get install -y ant
- name: Adjust firewall
run: |
sudo ufw allow out 3306/tcp
sudo ufw allow in 3306/tcp
- name: Setup MariaDB
uses: getong/mariadb-action@v1.1
with:
mariadb version: ${{ matrix.mariadb-version }}
mysql database: 'froxlor010'
mysql root password: 'fr0xl0r.TravisCI'
- name: Wait for database
run: sleep 15
- name: Setup databases
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 "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 < /tmp/froxlor.sql
- name: Run testing
run: ant quick-build
# - name: irc push
# uses: rectalogic/notify-irc@v1
# if: github.event_name == 'push'
# with:
# channel: "#froxlor"
# server: "irc.libera.chat"
# nickname: froxlor-ci
# message: |
# ${{ github.actor }} pushed ${{ github.event.ref }} ${{ github.event.compare }}
# ${{ join(github.event.commits.*.message) }}
# - name: irc pull request
# uses: rectalogic/notify-irc@v1
# if: github.event_name == 'pull_request'
# with:
# channel: "#froxlor"
# server: "irc.libera.chat"
# nickname: froxlor-ci
# message: |
# ${{ github.actor }} opened PR ${{ github.event.pull_request.html_url }}
# - name: irc tag created
# uses: rectalogic/notify-irc@v1
# if: github.event_name == 'create' && github.event.ref_type == 'tag'
# with:
# channel: "#froxlor"
# server: "irc.libera.chat"
# nickname: froxlor-ci
# message: |
# ${{ github.actor }} tagged ${{ github.repository }} ${{ github.event.ref }}

View File

@@ -1,59 +0,0 @@
name: Froxlor-CI-MySQL
on: ['push', 'pull_request', 'create']
jobs:
froxlor:
name: Froxlor (PHP ${{ matrix.php-versions }}, MySQL ${{ matrix.mysql-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: ['7.4', '8.1']
mysql-version: [8.0, 5.7]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: composer:v2
extensions: mbstring, xml, ctype, pdo_mysql, mysql, curl, json, zip, session, filter, posix, openssl, fileinfo, bcmath, gmp
- name: Install tools
run: sudo apt-get install -y ant
- name: Adjust firewall
run: |
sudo ufw allow out 3306/tcp
sudo ufw allow in 3306/tcp
- name: Setup MySQL
uses: samin/mysql-action@v1.3
with:
mysql version: ${{ matrix.mysql-version }}
mysql database: 'froxlor010'
mysql root password: 'fr0xl0r.TravisCI'
- name: Wait for database
run: sleep 15
- name: Setup database (8.0)
if: matrix.mysql-version == '8.0'
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 "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 < /tmp/froxlor.sql
- name: Setup database (5.7)
if: matrix.mysql-version == '5.7'
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 "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 < /tmp/froxlor.sql
- name: Run testing
run: ant quick-build

27
.gitignore vendored
View File

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

154
2fa.php
View File

@@ -1,154 +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\Database\Database;
use Froxlor\FroxlorLogger;
use Froxlor\FroxlorTwoFactorAuth;
use Froxlor\Settings;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Response;
use Froxlor\PhpHelper;
use Froxlor\User;
if (Settings::Get('2fa.enabled') != '1') {
Response::dynamicError('2fa.2fa_not_activated');
}
// This file is being included in admin_index and customer_index
// and therefore does not need to require lib/init.php
if (AREA == 'admin') {
$upd_stmt = Database::prepare("UPDATE `" . TABLE_PANEL_ADMINS . "` SET `type_2fa` = :t2fa, `data_2fa` = :d2fa WHERE adminid = :id");
$uid = $userinfo['adminid'];
} elseif (AREA == 'customer') {
$upd_stmt = Database::prepare("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `type_2fa` = :t2fa, `data_2fa` = :d2fa WHERE customerid = :id");
$uid = $userinfo['customerid'];
}
$success_message = "";
$tfa = new FroxlorTwoFactorAuth('Froxlor ' . Settings::Get('system.hostname'));
// do the delete and then just show a success-message
if ($action == 'delete') {
Database::pexecute($upd_stmt, [
't2fa' => 0,
'd2fa' => "",
'id' => $uid
]);
Response::standardSuccess('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') {
$type = isset($_POST['type_2fa']) ? $_POST['type_2fa'] : '0';
$data = isset($_POST['data_2fa']) ? $_POST['data_2fa'] : '';
$code = isset($_POST['codevalidation']) ? $_POST['codevalidation'] : '';
// validate
$result = $tfa->verifyCode($data, $code, 3);
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');
}
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed 2fa::overview");
$type_select_values = [];
$ga_qrcode = '';
if ($userinfo['type_2fa'] == '0') {
// available types
$type_select_values = [
0 => '-',
1 => 'E-Mail',
2 => 'Authenticator'
];
asort($type_select_values);
} elseif ($userinfo['type_2fa'] == '1') {
// email 2fa enabled
} elseif ($userinfo['type_2fa'] == '2') {
// authenticator 2fa enabled
$ga_qrcode = $tfa->getQRCodeImageAsDataUri($userinfo['loginname'], $userinfo['data_2fa']);
}
UI::view('user/2fa.html.twig', [
'type_select_values' => $type_select_values,
'ga_qrcode' => $ga_qrcode
]);

561
COPYING
View File

@@ -1,280 +1,281 @@
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
Version 2, June 1991 Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc. Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. of this license document, but changing it is not allowed.
Preamble Preamble
The licenses for most software are designed to take away your The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to the GNU Library General Public License instead.) You can apply it to
your programs, too. your programs, too.
When we speak of free software, we are referring to freedom, not When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things. in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights. anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it. distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their source code. And you must show them these terms so they know their
rights. rights.
We protect your rights with two steps: (1) copyright the software, and We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy, (2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software. distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original that any problems introduced by others will not reflect on the original
authors' reputations. authors' reputations.
Finally, any free program is threatened constantly by software Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all. patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and The precise terms and conditions for copying, distribution and
modification follow. modification follow.
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains 0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below, under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program" refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law: means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it, that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you". the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program). Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does. Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's 1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty; notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License and give any other recipients of the Program a copy of this License
along with the Program. along with the Program.
You may charge a fee for the physical act of transferring a copy, and You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee. you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion 2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1 distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions: above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change. stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License. parties under the terms of this License.
c) If the modified program normally reads commands interactively c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on does not normally print such an announcement, your work based on
the Program is not required to print an announcement.) the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program, identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it. entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or exercise the right to control the distribution of derivative or
collective works based on the Program. collective works based on the Program.
In addition, mere aggregation of another work not based on the Program In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under a storage or distribution medium does not bring the other work under
the scope of this License. the scope of this License.
3. You may copy and distribute the Program (or a work based on it, 3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following: Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or, 1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or, customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such received the program in object code or executable form with such
an offer, in accord with Subsection b above.) an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component operating system on which the executable runs, unless that component
itself accompanies the executable. itself accompanies the executable.
If distribution of executable or object code is made by offering If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not distribution of the source code, even though third parties are not
compelled to copy the source along with the object code. compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program 4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License. void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such this License will not have their licenses terminated so long as such
parties remain in full compliance. parties remain in full compliance.
5. You are not required to accept this License, since you have not 5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying all its terms and conditions for copying, distributing or modifying
the Program or works based on it. the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the 6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein. restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to You are not responsible for enforcing compliance by third parties to
this License. this License.
7. If, as a consequence of a court judgment or allegation of patent 7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues), infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program. refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other apply and the section as a whole is intended to apply in other
circumstances. circumstances.
It is not the purpose of this section to induce you to infringe any It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is integrity of the free software distribution system, which is
implemented by public license practices. Many people have made implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot to distribute software through any other system and a licensee cannot
impose that choice. impose that choice.
This section is intended to make thoroughly clear what is believed to This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License. be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in 8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License. the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions 9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to be similar in spirit to the present version, but may differ in detail to
address new problems or concerns. address new problems or concerns.
Each version is given a distinguishing version number. If the Program Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software this License, you may choose any version ever published by the Free Software
Foundation. Foundation.
10. If you wish to incorporate parts of the Program into other free 10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally. of promoting the sharing and reuse of software generally.
NO WARRANTY NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION. REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES. POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS END OF TERMS AND CONDITIONS

View File

@@ -1,82 +0,0 @@
[![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-mysql.yml/badge.svg?branch=main)](https://github.com/Froxlor/Froxlor/actions/workflows/build-mysql.yml)
[![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.froxlor.org)
# Froxlor
The server administration software for your needs.
Developed by experienced server administrators, this panel simplifies the effort of managing your hosting platform.
## Installation
### Fast install
1. Ensure that your webserver serves /var/www/html
2. Extract froxlor into /var/www/html
3. Point your browser to http://[ip-of-webserver]/froxlor
4. Follow the installer
5. Login as administrator
6. Have fun!
If you have chosen to do the configuration by hand during the installation, you have to complete some more steps:
1. Adjust "System > Settings" according to your needs
2. Choose your distribution under "System > Configuration"
3. Follow the steps for your services
### Detailed installation
https://docs.froxlor.org/latest/general/installation/
## Help
You may find help in the following places:
### Discord
The froxlor community discord server can be found here: https://discord.froxlor.org
### IRC
froxlor may be found on libera.chat, channel #froxlor:
irc://irc.libera.chat/froxlor
### Forum
The community is located on https://forum.froxlor.org/
### Wiki
More documentation may be found in the froxlor - documentation:
https://docs.froxlor.org/
## License
May be found in [COPYING](COPYING)
## Downloads
### 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)
### Debian / Ubutnu repository
[HowTo](https://docs.froxlor.org/latest/general/installation/apt-package.html)
#### Debian
```
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
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'
```
#### Ubuntu
```
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
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'
```
## Contributing
[see here](.github/CONTRIBUTING.md)

View File

@@ -1,47 +0,0 @@
# froxlor's Security Policy
Welcome and thanks for taking interest in [froxlor](https://www.froxlor.org)!
We are mostly interested in reports by actual froxlor users but all high quality contributions are welcome.
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.
With that, good luck hacking us ;)
## 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
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).

126
TODO Normal file
View File

@@ -0,0 +1,126 @@
FIXED 0001282 Homedirs von Dovecot identisch
FIXED 0001283 SysCP creating broken lighttpd config files
FIXED 0001213 APS class_apsinstaller.php on line 510 - error installing different apps
FIXED 0001272 Default Config for libnss incomplete (debian/lenny)
FIXED 0001281 Wrong open_basedir directive
FIXED 0001279 incorrect usage of escapeshellcmd
FIXED 0001269 AWStats RewriteRule is wrong
FIXED 0001277 Apache Redirect => permanent 301
FIXED 0001276 Bind Zones Not Updated on Nameserver Change
FIXED 0001275 Setting up Traffic limit is limited to 999 GB
FIXED 0001273 APS-Installer
FIXED 0001271 cant install the package magento
FIXED 0001270 xinet reltime update mistake
FIXED 0001268 SysCP Funktion: aktualisierung in Real-Time
FIXED 0001267 Domain-Aliases also create a HOST-entry
FIXED 0001266 Lighttpd has a internal limit of regex-hits which limits max amount of domain-aliases
FIXED 0001263 Cosmettic Change
FIXED 0001255 Wrong path to usage statistics under domain settings
FIXED 0001236 the cron doesnt delete user directories
FIXED 0001254 Installation no next button
FIXED 0001253 admin_customers.php line 803 / 804 contain the same
FIXED 0001250 Apache redirect to Umlautdomains does not work
FIXED 0001249 SysCP SVN(!) settings loader doesn't load some settings
FIXED 0001247 tab order problems at email forward mask
FIXED 0001246 wrong variable assigned in /templates/admin/customers/customers_add.tpl
FIXED 0001239 awstats configs get cluttered up after domain deletion
FIXED 0001228 Domain deletion fails
FIXED 0001233 Display errors when amount of FTP or Mail Traffic is larger than HTTP traffic
FIXED 0001122 Field members of table ftp_groups not updated correctly when customer deletes ftp user
FIXED 0001215 php.ini: open_basedir error
FIXED 0001223 Postfix proposed SQL-query in mysql-virtual_alias_maps.cf: use TRIM()
FIXED 0001221 syscp xinet.d - no need to edit /etc/services
FIXED 0001217 SysCP Realtime Support
FIXED 0001209 APS crashs when installing magento
FIXED 0001210 Add start- and endtime to autoresponder
FIXED 0001185 Autoreponder - send mails via sendmail to set correct Return-Path header
FIXED 0001201 Virtualusers conflict with local users when using libnss-mysql
FIXED 0001203 Add check for PHP version and required PHP modules in install script
FIXED 0001013 lighttpd - every customer should have his own php.ini
FIXED 0001113 realtime functionality broken
FIXED 0001080 host of third level gets overridden by second-level when wwwserveralias is not set on lighttpd
FIXED 0001159 serveral errors for lighttpd
FIXED 0001181 lighttpd cronjob config for subdomains is empty
FIXED 0001176 libnss-mysql and conflicting usernames/groups
FIXED 0001154 Wrong configuration set with AWstats an fcgi
FIXED 0001149 Create a Configuration-Option for SPF Records in Zonefiles
FIXED 0001095 lighttpd - redirection - "/" slash is added to end of url
FIXED 0001148 Show info for inactive modifications
FIXED 0001051 include_shell issue in lighttpd 1.4.20
--------------------------------------------------------------------------------------------------------------
WONFIX 0001278 Customer and domain directories are not created
WONTFIX 0001056 Need extra payment methods
WONTFIX 0001262 Currency type modification.
WONTFIX 0001257 Fee is recalculated with current contract data although interval is over
WONTFIX 0001260 2x F5 causes bigger fonts
WONTFIX 0001259 contract-changes optional with cron to the end of the interval
WONTFIX 0001258 Make invoices immediately
WONTFIX 0001252 Backup Cronjob for Customers
WONTFIX 0001248 blog.syscp.org
WONTFIX 0001243 Wrong uid and gid for php-fcgi-starter
WONTIFX 0001241 Patch for facilate customizing syscp
WONTFIX 0001227 Error on fixing invoices with credit notes
WONTFIX 0001039 Additional text field for infos in customers "Contact Data"
WONTFIX 0001187 additional Invoices
WONTFIX 0001059 Billing - Create contract - Filename should contain customername
WONTFIX 0001112 customers should be able to create custom cronjobs
WONTFIX 0001136 Configuration of "dead" mail adresses
WONTFIX 0001134 Allow selection of a default apache page / provide access to syscp
WONTFIX 0001104 Listen Configuration should contain a warning for debian
WONTFIX 0001098 Possibillity to dissable "Catchall" for mails
WONTFIX 0001033 Cron-Tasks: creating of php.ini
--------------------------------------------------------------------------------------------------------------
0001274 Option to mark a Domain as Subdomain possible or not
0001280 deb packet 1.4.2.1-2 fu*ked
0001041 Customer should have access to his webserver logs.
0001261 No e-mail on 90% traffic
0001120 Missing function to calculate the mail traffic
0001244 customer view too wide for 1024x768 resolutions
0001229 subdomains and Own vHost-Settings
0001251 possibility to manage WebDAV config in SysCP
0001042 Webalizer dir should not be deletable
0001245 Password Protect /awstats/ when using awstats and fcgid
0001156 Repairing use of awstats and awstats-icons with fcgi
0001242 When email qouta is enabled, you cannot add more resources to a client.
0001240 Wrong php.ini for subdomains with fastCGI
0001224 APS installer not installing the aps applications properly, such as WordPress and WebCalender
0001017 Proftpd - Quota should be added
0001016 Pureftpd - quota should be added
0001206 crontabs not terminating
0001212 retain form input
0001211 Generated MySQL username too long
0001208 HTML Tags in Support Tickets
0001207 FTP Passw<73>rter mit Umlauten
0001204 php5-suhosin
0001198 More online help wanted
0001189 Autoresponder: support for multiline "From:" headers
0001186 subdomains and php configuration
0001079 Protected dir only works only after a force-reload on lighttpd
0001034 Cron-Tasks: apache-logfiles directory
0001150 Wrong configuration of awstats
0001083 awstats.model.conf.syscp should include awstats.conf
0001152 apache certificate is not generated
0001151 When cronjob generates new dkim files a mail is sent to root
0001005 Force user to add POP3 Account before he can add e-mail adresses
0001142 Default index.html should be placed in a sub-directory of a domain.
0001140 Replace variables in defaut_vhost config
0001138 old db-data is lost when mysqldump is not within open_basedir
0001135 dkim refers to non-existing domainkey entry in DNS zone file.
0001133 Default Configuration doesn't allow Exim4 to forward Mails to the outside world
0001128 More targets for "Write a message" tool
0001131 Add FreeBSD configuration files to the base tarball.
0001130 Wrong number format in e.g. traffic display.
0001129 Allow selection of automatic creation of a webmail.<domain>.<tld>, phpmyadmin. ..., webftp. ...
0001127 Versioning of configuration templates.
0001116 Please add tooltips to adminCP
0001114 Password query for Awstats statistics
0001111 add login for e-mail and ftp users to let them change their own settings
0001109 no mail traffic is shown and calculated without third party module
0001101 Default mail qouta - possibillity to set new accounts to amount of webspace
0001084 Add select box to change special logfile setting on domain edit
0001058 Add id/class attributs in <img> tag (left navigation)
0001043 When creating customer it should also be possible to add domains (merge customer & domain menu)
0001035 PHP-Error-Log | Adminpanel & CronTask
0001010 Send info mail to customer if webspace is exceeded
0001004 Ressources / Domains - Standard subdomains should be separrated from normal Domains
9999999 Write a complete statement about what froxlor is and why we do this (atari)

View File

@@ -0,0 +1,72 @@
<?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 Settings
* @version $Id$
*/
return array(
'groups' => array(
'version' => array(
'fields' => array(
'panel_version' => array(
'settinggroup' => 'panel',
'varname' => 'version',
'type' => 'hidden',
'default' => '',
),
'panel_frontend' => array(
'settinggroup' => 'panel',
'varname' => 'frontend',
'type' => 'hidden',
'default' => '',
),
'system_last_tasks_run' => array(
'settinggroup' => 'system',
'varname' => 'last_tasks_run',
'type' => 'hidden',
'default' => '',
'save_method' => 'storeSettingField',
),
'system_last_traffic_run' => array(
'settinggroup' => 'system',
'varname' => 'last_traffic_run',
'type' => 'hidden',
'default' => '',
),
'system_lastcronrun' => array(
'settinggroup' => 'system',
'varname' => 'lastcronrun',
'type' => 'hidden',
'default' => '',
),
'system_lastguid' => array(
'settinggroup' => 'system',
'varname' => 'lastguid',
'type' => 'hidden',
'default' => 9999,
),
'system_lastaccountnumber' => array(
'settinggroup' => 'system',
'varname' => 'lastaccountnumber',
'type' => 'hidden',
'default' => 0,
),
),
),
),
);
?>

View File

@@ -2,342 +2,164 @@
/** /**
* 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 * @version $Id$
* 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 [ return array(
'groups' => [ 'groups' => array(
'panel' => [ 'panel' => array(
'title' => lng('admin.panelsettings'), 'title' => $lng['admin']['panelsettings'],
'icon' => 'fa-solid fa-chalkboard-user', 'fields' => array(
'fields' => [ 'panel_standardlanguage' => array(
'panel_standardlanguage' => [ 'label' => array('title' => $lng['login']['language'], 'description' => $lng['serversettings']['language']['description']),
'label' => [
'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' => 'getLanguages',
'getLanguages' 'save_method' => 'storeSettingField',
], ),
'save_method' => 'storeSettingField' 'panel_natsorting' => array(
], 'label' => $lng['serversettings']['natsorting'],
'panel_default_theme' => [
'label' => [
'title' => lng('panel.theme'),
'description' => lng('serversettings.default_theme')
],
'settinggroup' => 'panel',
'varname' => 'default_theme',
'type' => 'select',
'default' => 'Froxlor',
'option_options_method' => [
'\\Froxlor\\UI\\Panel\\UI',
'getThemes'
],
'save_method' => 'storeSettingDefaultTheme'
],
'panel_allow_theme_change_customer' => [
'label' => lng('serversettings.panel_allow_theme_change_customer'),
'settinggroup' => 'panel',
'varname' => 'allow_theme_change_customer',
'type' => 'checkbox',
'default' => true,
'save_method' => 'storeSettingField'
],
'panel_allow_theme_change_admin' => [
'label' => lng('serversettings.panel_allow_theme_change_admin'),
'settinggroup' => 'panel',
'varname' => 'allow_theme_change_admin',
'type' => 'checkbox',
'default' => true,
'save_method' => 'storeSettingField'
],
'panel_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_no_robots' => array(
'panel_paging' => [ 'label' => $lng['serversettings']['no_robots'],
'label' => lng('serversettings.paging'), 'settinggroup' => 'panel',
'varname' => 'no_robots',
'type' => 'bool',
'default' => false,
'save_method' => 'storeSettingField',
),
'panel_paging' => array(
'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('Manual' => 'Manual', 'Dropdown' => 'Dropdown'),
'Dropdown' => lng('serversettings.dropdown') 'save_method' => 'storeSettingField',
], ),
'save_method' => 'storeSettingField' 'panel_adminmail' => array(
], 'label' => $lng['serversettings']['adminmail'],
'panel_adminmail' => [
'label' => lng('serversettings.adminmail'),
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'adminmail', 'varname' => 'adminmail',
'type' => 'email', 'type' => 'string',
'string_emptyallowed' => true, 'string_type' => 'mail',
'default' => '', 'string_emptyallowed' => false,
'save_method' => 'storeSettingField'
],
'panel_adminmail_defname' => [
'label' => lng('serversettings.adminmail_defname'),
'settinggroup' => 'panel',
'varname' => 'adminmail_defname',
'type' => 'text',
'default' => 'Froxlor Administrator',
'save_method' => 'storeSettingField'
],
'panel_adminmail_return' => [
'label' => lng('serversettings.adminmail_return'),
'settinggroup' => 'panel',
'varname' => 'adminmail_return',
'type' => 'email',
'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_froxlor_graphic' => array(
'label' => lng('admin.show_news_feed'), 'label' => $lng['admin']['froxlor_graphic'],
'settinggroup' => 'admin', 'settinggroup' => 'admin',
'varname' => 'show_news_feed', 'varname' => 'froxlor_graphic',
'type' => 'checkbox', 'type' => 'string',
'default' => false,
'save_method' => 'storeSettingField'
],
'customer_show_news_feed' => [
'label' => lng('admin.customer_show_news_feed'),
'settinggroup' => 'customer',
'varname' => 'show_news_feed',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField'
],
'customer_news_feed_url' => [
'label' => lng('admin.customer_news_feed_url'),
'settinggroup' => 'customer',
'varname' => 'news_feed_url',
'type' => 'url',
'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_hidesubdomains' => [ ),
'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',
'varname' => 'phpconfigs_hidestdsubdomain',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'panel_customer_hide_options' => [
'label' => lng('serversettings.panel_customer_hide_options'),
'settinggroup' => 'panel',
'varname' => 'customer_hide_options',
'type' => 'select',
'default' => '',
'select_mode' => 'multiple',
'option_emptyallowed' => true,
'select_var' => [
'email' => lng('menue.email.email'),
'mysql' => lng('menue.mysql.mysql'),
'domains' => lng('menue.domains.domains'),
'ftp' => lng('menue.ftp.ftp'),
'extras' => lng('menue.extras.extras'),
'extras.directoryprotection' => lng('menue.extras.extras') . " / " . lng('menue.extras.directoryprotection'),
'extras.pathoptions' => lng('menue.extras.extras') . " / " . lng('menue.extras.pathoptions'),
'extras.logger' => lng('menue.extras.extras') . " / " . lng('menue.logger.logger'),
'extras.backup' => lng('menue.extras.extras') . " / " . lng('menue.extras.backup'),
'traffic' => lng('menue.traffic.traffic'),
'traffic.http' => lng('menue.traffic.traffic') . " / HTTP",
'traffic.ftp' => lng('menue.traffic.traffic') . " / FTP",
'traffic.mail' => lng('menue.traffic.traffic') . " / Mail"
],
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'panel_imprint_url' => [
'label' => lng('serversettings.imprint_url'),
'settinggroup' => 'panel',
'varname' => 'imprint_url',
'type' => 'url',
'string_emptyallowed' => true,
'default' => '',
'save_method' => 'storeSettingField'
],
'panel_terms_url' => [
'label' => lng('serversettings.terms_url'),
'settinggroup' => 'panel',
'varname' => 'terms_url',
'type' => 'url',
'string_emptyallowed' => true,
'default' => '',
'save_method' => 'storeSettingField'
],
'panel_privacy_url' => [
'label' => lng('serversettings.privacy_url'),
'settinggroup' => 'panel',
'varname' => 'privacy_url',
'type' => 'url',
'string_emptyallowed' => true,
'default' => '',
'save_method' => 'storeSettingField'
],
'panel_logo_overridetheme' => [
'label' => lng('serversettings.logo_overridetheme'),
'settinggroup' => 'panel',
'varname' => 'logo_overridetheme',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField'
],
'panel_logo_overridecustom' => [
'label' => lng('serversettings.logo_overridecustom'),
'settinggroup' => 'panel',
'varname' => 'logo_overridecustom',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField'
],
'panel_logo_image_header' => [
'label' => lng('serversettings.logo_image_header'),
'settinggroup' => 'panel',
'varname' => 'logo_image_header',
'type' => 'image',
'accept' => 'image/jpeg, image/jpg, image/png, image/gif',
'image_name' => 'logo_header',
'default' => '',
'save_method' => 'storeSettingImage'
],
'panel_logo_image_login' => [
'label' => lng('serversettings.logo_image_login'),
'settinggroup' => 'panel',
'varname' => 'logo_image_login',
'type' => 'image',
'accept' => 'image/jpeg, image/jpg, image/png, image/gif',
'image_name' => 'logo_login',
'default' => '',
'save_method' => 'storeSettingImage'
]
]
]
]
];

View File

@@ -2,236 +2,111 @@
/** /**
* 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 * @version $Id$
* 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 [ return array(
'groups' => [ 'groups' => array(
'accounts' => [ 'accounts' => array(
'title' => lng('admin.accountsettings'), 'title' => $lng['admin']['accountsettings'],
'icon' => 'fa-solid fa-users-gear', 'fields' => array(
'fields' => [ 'session_sessiontimeout' => array(
'session_sessiontimeout' => [ 'label' => $lng['serversettings']['session_timeout'],
'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_maxloginattempts' => array(
'label' => lng('serversettings.login_domain_login'), 'label' => $lng['serversettings']['maxloginattempts'],
'settinggroup' => 'login',
'varname' => 'domain_login',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField'
],
'login_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'
],
'2fa_enabled' => [
'label' => lng('2fa.2fa_enabled'),
'settinggroup' => '2fa',
'varname' => 'enabled',
'type' => 'checkbox',
'default' => true,
'save_method' => 'storeSettingField'
],
'panel_password_min_length' => [
'label' => lng('serversettings.panel_password_min_length'),
'settinggroup' => 'panel',
'varname' => 'password_min_length',
'type' => 'number',
'min' => 0,
'default' => 0,
'save_method' => 'storeSettingField'
],
'panel_password_alpha_lower' => [
'label' => lng('serversettings.panel_password_alpha_lower'),
'settinggroup' => 'panel',
'varname' => 'password_alpha_lower',
'type' => 'checkbox',
'default' => true,
'save_method' => 'storeSettingField'
],
'panel_password_alpha_upper' => [
'label' => lng('serversettings.panel_password_alpha_upper'),
'settinggroup' => 'panel',
'varname' => 'password_alpha_upper',
'type' => 'checkbox',
'default' => true,
'save_method' => 'storeSettingField'
],
'panel_password_numeric' => [
'label' => lng('serversettings.panel_password_numeric'),
'settinggroup' => 'panel',
'varname' => 'password_numeric',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField'
],
'panel_password_special_char_required' => [
'label' => lng('serversettings.panel_password_special_char_required'),
'settinggroup' => 'panel',
'varname' => 'password_special_char_required',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField'
],
'panel_password_special_char' => [
'label' => lng('serversettings.panel_password_special_char'),
'settinggroup' => 'panel',
'varname' => 'password_special_char',
'type' => 'text',
'default' => '!?<>§$%+#=@',
'save_method' => 'storeSettingField'
],
'panel_password_regex' => [
'label' => lng('serversettings.panel_password_regex'),
'settinggroup' => 'panel',
'varname' => 'password_regex',
'type' => 'text',
'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' => 'checkUsername',
'\\Froxlor\\Validate\\Check', 'save_method' => 'storeSettingField',
'checkUsername' ),
], 'customer_mysqlprefix' => array(
'save_method' => 'storeSettingField' 'label' => $lng['serversettings']['mysqlprefix'],
],
'customer_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' => 'checkUsername',
'\\Froxlor\\Validate\\Check', 'save_method' => 'storeSettingField',
'checkUsername' ),
], 'customer_ftpprefix' => array(
'save_method' => 'storeSettingField' 'label' => $lng['serversettings']['ftpprefix'],
],
'customer_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' => [ ),
'fieldname' => 'panel_allow_preset_admin', 'panel_allow_preset_admin' => array(
'fielddata' => [ 'label' => $lng['serversettings']['allow_password_reset_admin'],
'settinggroup' => 'panel',
'varname' => 'allow_preset_admin'
],
'onlyif' => 0
]
],
'panel_allow_preset_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' => [ ),
'fieldname' => 'panel_allow_preset', ),
'fielddata' => [ ),
'settinggroup' => 'panel', ),
'varname' => 'allow_preset' );
],
'onlyif' => 1 ?>
]
],
'system_backupenabled' => [
'label' => lng('serversettings.backupenabled'),
'settinggroup' => 'system',
'varname' => 'backupenabled',
'type' => 'checkbox',
'default' => false,
'cronmodule' => 'froxlor/backup',
'save_method' => 'storeSettingField'
],
'system_createstdsubdom_default' => [
'label' => lng('serversettings.createstdsubdom_default'),
'settinggroup' => 'system',
'varname' => 'createstdsubdom_default',
'type' => 'select',
'default' => '1',
'select_var' => [
'0' => lng('panel.no'),
'1' => lng('panel.yes')
],
'save_method' => 'storeSettingField'
],
]
]
]
];

View File

@@ -2,321 +2,112 @@
/** /**
* 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 * @version $Id$
* 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 [ return array(
'groups' => [ 'groups' => array(
'system' => [ 'system' => array(
'title' => lng('admin.systemsettings'), 'title' => $lng['admin']['systemsettings'],
'icon' => 'fa-solid fa-gears', 'fields' => array(
'fields' => [ 'system_documentroot_prefix' => array(
'system_documentroot_prefix' => [ 'label' => $lng['serversettings']['documentroot_prefix'],
'label' => lng('serversettings.documentroot_prefix'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'documentroot_prefix', 'varname' => 'documentroot_prefix',
'type' => 'text', 'type' => 'string',
'string_type' => 'dir',
'default' => '/var/customers/webs/', 'default' => '/var/customers/webs/',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'plausibility_check_method' => [ ),
'\\Froxlor\\Validate\\Check', 'system_ipaddress' => array(
'checkPathConflicts' 'label' => $lng['serversettings']['ipaddress'],
],
'requires_reconf' => ['http']
],
'system_documentroot_use_default_value' => [
'label' => lng('serversettings.documentroot_use_default_value'),
'settinggroup' => 'system',
'varname' => 'documentroot_use_default_value',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField'
],
'system_ipaddress' => [
'label' => lng('serversettings.ipaddress'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'ipaddress', 'varname' => 'ipaddress',
'type' => 'select', 'type' => 'option',
'option_options_method' => [ 'option_mode' => 'one',
'\\Froxlor\\Domain\\IpAddr', 'option_options_method' => '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' => 'one',
'option_options_method' => [ 'option_options_method' => 'getIpPortCombinations',
'\\Froxlor\\Domain\\IpAddr',
'getIpPortCombinations'
],
'default' => '', 'default' => '',
'save_method' => 'storeSettingDefaultIp' 'save_method' => 'storeSettingDefaultIp',
], ),
'system_defaultsslip' => [ 'system_hostname' => array(
'label' => lng('serversettings.defaultsslip'), 'label' => $lng['serversettings']['hostname'],
'settinggroup' => 'system',
'varname' => 'defaultsslip',
'type' => 'select',
'select_mode' => 'multiple',
'option_options_method' => [
'\\Froxlor\\Domain\\IpAddr',
'getSslIpPortCombinations'
],
'default' => '',
'save_method' => 'storeSettingDefaultSslIp'
],
'system_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' => [ ),
'\\Froxlor\\Validate\\Check', 'system_mysql_access_host' => array(
'checkHostname' 'label' => $lng['serversettings']['mysql_access_host'],
]
],
'api_enabled' => [
'label' => lng('serversettings.enable_api'),
'settinggroup' => 'api',
'varname' => 'enabled',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField'
],
'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_validatedomain' => [
'label' => lng('serversettings.validate_domain'),
'settinggroup' => 'system',
'varname' => 'validate_domain',
'type' => 'checkbox',
'default' => true,
'save_method' => 'storeSettingField'
],
'system_stdsubdomain' => [
'label' => lng('serversettings.stdsubdomainhost'),
'settinggroup' => 'system',
'varname' => 'stdsubdomain',
'type' => 'text',
'default' => '',
'save_method' => 'storeSettingHostname'
],
'system_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' => 'checkMysqlAccessHost',
'\\Froxlor\\Validate\\Check', 'save_method' => 'storeSettingMysqlAccessHost',
'checkMysqlAccessHost' ),
], 'system_realtime_port' => array(
'save_method' => 'storeSettingMysqlAccessHost' 'label' => $lng['serversettings']['system_realtime_port'],
],
'system_nssextrausers' => [
'label' => lng('serversettings.nssextrausers'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'nssextrausers', 'varname' => 'realtime_port',
'type' => 'checkbox', 'type' => 'int',
'default' => false, 'int_max' => 65535,
'save_method' => 'storeSettingField' 'default' => 0,
], 'save_method' => 'storeSettingField',
'system_index_file_extension' => [ ),
'label' => lng('serversettings.index_file_extension'), 'system_index_file_extension' => array(
'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_httpuser' => array(
'system_store_index_file_subs' => [
'label' => lng('serversettings.system_store_index_file_subs'),
'settinggroup' => 'system',
'varname' => 'store_index_file_subs',
'type' => 'checkbox',
'default' => true,
'save_method' => 'storeSettingField'
],
'system_httpuser' => [
'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_debug_cron' => array(
'label' => lng('serversettings.report.report'), 'label' => $lng['serversettings']['cron']['debug'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'report_enable', 'varname' => 'debug_cron',
'type' => 'checkbox', 'type' => 'bool',
'default' => true,
'cronmodule' => 'froxlor/reports',
'save_method' => 'storeSettingField'
],
'system_report_webmax' => [
'label' => lng('serversettings.report.webmax'),
'settinggroup' => 'system',
'varname' => 'report_webmax',
'type' => 'number',
'min' => 0,
'max' => 150,
'default' => 90,
'save_method' => 'storeSettingField'
],
'system_report_trafficmax' => [
'label' => lng('serversettings.report.trafficmax'),
'settinggroup' => 'system',
'varname' => 'report_trafficmax',
'type' => 'number',
'min' => 0,
'max' => 150,
'default' => 90,
'save_method' => 'storeSettingField'
],
'system_mail_use_smtp' => [
'label' => lng('serversettings.mail_use_smtp'),
'settinggroup' => 'system',
'varname' => 'mail_use_smtp',
'type' => 'checkbox',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField'
],
'system_mail_smtp_host' => [
'label' => lng('serversettings.mail_smtp_host'),
'settinggroup' => 'system',
'varname' => 'mail_smtp_host',
'type' => 'text',
'default' => 'localhost',
'save_method' => 'storeSettingField'
],
'system_mail_smtp_port' => [
'label' => lng('serversettings.mail_smtp_port'),
'settinggroup' => 'system',
'varname' => 'mail_smtp_port',
'type' => 'number',
'min' => 1,
'max' => 65535,
'default' => 25,
'save_method' => 'storeSettingField'
],
'system_mail_smtp_usetls' => [
'label' => lng('serversettings.mail_smtp_usetls'),
'settinggroup' => 'system',
'varname' => 'mail_smtp_usetls',
'type' => 'checkbox',
'default' => true,
'save_method' => 'storeSettingField'
],
'system_mail_smtp_auth' => [
'label' => lng('serversettings.mail_smtp_auth'),
'settinggroup' => 'system',
'varname' => 'mail_smtp_auth',
'type' => 'checkbox',
'default' => true,
'save_method' => 'storeSettingField'
],
'system_mail_smtp_user' => [
'label' => lng('serversettings.mail_smtp_user'),
'settinggroup' => 'system',
'varname' => 'mail_smtp_user',
'type' => 'text',
'default' => '',
'save_method' => 'storeSettingField'
],
'system_mail_smtp_passwd' => [
'label' => lng('serversettings.mail_smtp_passwd'),
'settinggroup' => 'system',
'varname' => 'mail_smtp_passwd',
'type' => 'password',
'default' => '',
'save_method' => 'storeSettingField'
],
'system_apply_specialsettings_default' => [
'label' => lng('serversettings.apply_specialsettings_default'),
'settinggroup' => 'system',
'varname' => 'apply_specialsettings_default',
'type' => 'checkbox',
'default' => true,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'advanced_mode' => true ),
], ),
'system_apply_phpconfigs_default' => [ ),
'label' => lng('serversettings.apply_phpconfigs_default'), ),
'settinggroup' => 'system', );
'varname' => 'apply_phpconfigs_default',
'type' => 'checkbox', ?>
'default' => true,
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'system_domaindefaultalias' => [
'label' => lng('admin.domaindefaultalias'),
'settinggroup' => 'system',
'varname' => 'domaindefaultalias',
'type' => 'select',
'default' => '0',
'select_var' => [
'0' => lng('domains.serveraliasoption_wildcard'),
'1' => lng('domains.serveraliasoption_www'),
'2' => lng('domains.serveraliasoption_none')
],
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'hide_incompatible_settings' => [
'label' => lng('serversettings.hide_incompatible_settings'),
'settinggroup' => 'system',
'varname' => 'hide_incompatible_settings',
'type' => 'checkbox',
'default' => true,
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
]
]
]
];

View File

@@ -1,297 +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
*/
use Froxlor\Settings;
return [
'groups' => [
'froxlorvhost' => [
'title' => lng('admin.froxlorvhost') . (call_user_func([
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
]) == false ? lng('admin.novhostcontainer') : ''),
'icon' => 'fa-solid fa-wrench',
'fields' => [
/**
* Webserver-Vhost
*/
'system_froxlordirectlyviahostname' => [
'label' => lng('serversettings.froxlordirectlyviahostname'),
'settinggroup' => 'system',
'varname' => 'froxlordirectlyviahostname',
'type' => 'checkbox',
'default' => true,
'save_method' => 'storeSettingField'
],
'system_froxloraliases' => [
'label' => lng('serversettings.froxloraliases'),
'settinggroup' => 'system',
'varname' => 'froxloraliases',
'type' => 'text',
'string_regexp' => '/^(([a-z0-9\-\._]+, ?)*[a-z0-9\-\._]+)?$/i',
'string_emptyallowed' => true,
'default' => '',
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
/**
* SSL / Let's Encrypt
*/
'system_le_froxlor_enabled' => [
'label' => lng('serversettings.le_froxlor_enabled'),
'settinggroup' => 'system',
'varname' => 'le_froxlor_enabled',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingClearCertificates',
'visible' => Settings::Get('system.leenabled') && call_user_func([
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
], true),
'requires_reconf' => ['http']
],
'system_le_froxlor_redirect' => [
'label' => lng('serversettings.le_froxlor_redirect'),
'settinggroup' => 'system',
'varname' => 'le_froxlor_redirect',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.use_ssl') && call_user_func([
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
], true)
],
'system_hsts_maxage' => [
'label' => lng('admin.domain_hsts_maxage'),
'settinggroup' => 'system',
'varname' => 'hsts_maxage',
'type' => 'number',
'min' => 0,
'max' => 94608000, // 3-years
'default' => 10368000,
'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.use_ssl') && call_user_func([
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
], true),
'advanced_mode' => true
],
'system_hsts_incsub' => [
'label' => lng('admin.domain_hsts_incsub'),
'settinggroup' => 'system',
'varname' => 'hsts_incsub',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.use_ssl') && call_user_func([
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
], true),
'advanced_mode' => true
],
'system_hsts_preload' => [
'label' => lng('admin.domain_hsts_preload'),
'settinggroup' => 'system',
'varname' => 'hsts_preload',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.use_ssl') && call_user_func([
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
], true),
'advanced_mode' => true
],
'system_honorcipherorder' => [
'label' => lng('admin.domain_honorcipherorder'),
'settinggroup' => 'system',
'varname' => 'honorcipherorder',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.use_ssl') && call_user_func([
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
], true),
'advanced_mode' => true
],
'system_sessiontickets' => [
'label' => lng('admin.domain_sessiontickets'),
'settinggroup' => 'system',
'varname' => 'sessiontickets',
'type' => 'checkbox',
'default' => true,
'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.use_ssl') && call_user_func([
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
], true),
'advanced_mode' => true
],
/**
* FCGID
*/
'system_mod_fcgid_enabled_ownvhost' => [
'label' => lng('serversettings.mod_fcgid_ownvhost'),
'settinggroup' => 'system',
'varname' => 'mod_fcgid_ownvhost',
'type' => 'checkbox',
'default' => true,
'save_method' => 'storeSettingField',
'websrv_avail' => [
'apache2'
],
'visible' => Settings::Get('system.mod_fcgid') && call_user_func([
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
]),
'requires_reconf' => ['system:fcgid']
],
'system_mod_fcgid_httpuser' => [
'label' => lng('admin.mod_fcgid_user'),
'settinggroup' => 'system',
'varname' => 'mod_fcgid_httpuser',
'type' => 'text',
'default' => 'froxlorlocal',
'save_method' => 'storeSettingWebserverFcgidFpmUser',
'websrv_avail' => [
'apache2'
],
'visible' => Settings::Get('system.mod_fcgid') && call_user_func([
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
]),
'requires_reconf' => ['system:fcgid']
],
'system_mod_fcgid_httpgroup' => [
'label' => lng('admin.mod_fcgid_group'),
'settinggroup' => 'system',
'varname' => 'mod_fcgid_httpgroup',
'type' => 'text',
'default' => 'froxlorlocal',
'save_method' => 'storeSettingField',
'websrv_avail' => [
'apache2'
],
'visible' => Settings::Get('system.mod_fcgid') && call_user_func([
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
]),
'requires_reconf' => ['system:fcgid']
],
'system_mod_fcgid_defaultini_ownvhost' => [
'label' => lng('serversettings.mod_fcgid.defaultini_ownvhost'),
'settinggroup' => 'system',
'varname' => 'mod_fcgid_defaultini_ownvhost',
'type' => 'select',
'default' => '2',
'option_options_method' => [
'\\Froxlor\\Http\\PhpConfig',
'getPhpConfigs'
],
'save_method' => 'storeSettingField',
'websrv_avail' => [
'apache2'
],
'visible' => Settings::Get('system.mod_fcgid') && call_user_func([
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
])
],
/**
* php-fpm
*/
'system_phpfpm_enabled_ownvhost' => [
'label' => lng('phpfpm.ownvhost'),
'settinggroup' => 'phpfpm',
'varname' => 'enabled_ownvhost',
'type' => 'checkbox',
'default' => true,
'save_method' => 'storeSettingField',
'visible' => Settings::Get('phpfpm.enabled') && call_user_func([
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
]),
'requires_reconf' => ['system:php-fpm']
],
'system_phpfpm_httpuser' => [
'label' => lng('phpfpm.vhost_httpuser'),
'settinggroup' => 'phpfpm',
'varname' => 'vhost_httpuser',
'type' => 'text',
'default' => 'froxlorlocal',
'save_method' => 'storeSettingWebserverFcgidFpmUser',
'visible' => Settings::Get('phpfpm.enabled') && call_user_func([
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
]),
'requires_reconf' => ['system:php-fpm']
],
'system_phpfpm_httpgroup' => [
'label' => lng('phpfpm.vhost_httpgroup'),
'settinggroup' => 'phpfpm',
'varname' => 'vhost_httpgroup',
'type' => 'text',
'default' => 'froxlorlocal',
'save_method' => 'storeSettingField',
'visible' => Settings::Get('phpfpm.enabled') && call_user_func([
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
]),
'requires_reconf' => ['system:php-fpm']
],
'system_phpfpm_defaultini_ownvhost' => [
'label' => lng('serversettings.mod_fcgid.defaultini_ownvhost'),
'settinggroup' => 'phpfpm',
'varname' => 'vhost_defaultini',
'type' => 'select',
'default' => '2',
'option_options_method' => [
'\\Froxlor\\Http\\PhpConfig',
'getPhpConfigs'
],
'save_method' => 'storeSettingField',
'visible' => Settings::Get('phpfpm.enabled') && call_user_func([
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
])
],
/**
* DNS
*/
'system_dns_createhostnameentry' => [
'label' => lng('serversettings.dns_createhostnameentry'),
'settinggroup' => 'system',
'varname' => 'dns_createhostnameentry',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.bind_enable')
]
]
]
]
];

View File

@@ -1,71 +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
*/
return [
'groups' => [
'crond' => [
'title' => lng('admin.cronsettings'),
'icon' => 'fa-solid fa-clock-rotate-left',
'advanced_mode' => true,
'fields' => [
'system_cronconfig' => [
'label' => lng('serversettings.system_cronconfig'),
'settinggroup' => 'system',
'varname' => 'cronconfig',
'type' => 'text',
'string_type' => 'file',
'default' => '/etc/cron.d/froxlor',
'save_method' => 'storeSettingField'
],
'system_croncmdline' => [
'label' => lng('serversettings.system_croncmdline'),
'settinggroup' => 'system',
'varname' => 'croncmdline',
'type' => 'text',
'string_regexp' => '/^[a-z0-9\/\._\- ]+$/i',
'default' => '/usr/bin/nice -n 5 /usr/bin/php -q',
'save_method' => 'storeSettingField'
],
'system_crondreload' => [
'label' => lng('serversettings.system_crondreload'),
'settinggroup' => 'system',
'varname' => 'crondreload',
'type' => 'text',
'string_regexp' => '/^[a-z0-9\/\._\- ]+$/i',
'default' => '/etc/init.d/cron reload',
'save_method' => 'storeSettingField'
],
'system_cron_allowautoupdate' => [
'label' => lng('serversettings.system_cron_allowautoupdate'),
'settinggroup' => 'system',
'varname' => 'cron_allowautoupdate',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField'
]
]
]
]
];

View File

@@ -2,423 +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 Settings
* You should have received a copy of the GNU General Public License * @version $Id$
* 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\Settings; return array(
'groups' => array(
return [ 'webserver' => array(
'groups' => [ 'title' => $lng['admin']['webserversettings'],
'webserver' => [ 'fields' => array(
'title' => lng('admin.webserversettings'), 'system_webserver' => array(
'icon' => 'fa-solid fa-server', 'label' => $lng['admin']['webserver'],
'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',
'apache2' => 'Apache 2', 'option_options' => array('apache2' => 'Apache 2', 'lighttpd' => 'ligHTTPd'),
'lighttpd' => 'ligHTTPd',
'nginx' => 'Nginx'
],
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'plausibility_check_method' => [ ),
'\\Froxlor\\Validate\\Check', 'system_apacheconf_vhost' => array(
'checkPhpInterfaceSetting' 'label' => $lng['serversettings']['apacheconf_vhost'],
],
'requires_reconf' => ['http']
],
'system_apache_24' => [
'label' => lng('serversettings.apache_24'),
'settinggroup' => 'system',
'varname' => 'apache24',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField',
'websrv_avail' => [
'apache2'
]
],
'system_apache_itksupport' => [
'label' => lng('serversettings.apache_itksupport'),
'settinggroup' => 'system',
'varname' => 'apacheitksupport',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField',
'visible' => (Settings::Get('system.mod_fcgid') == 0 && Settings::Get('phpfpm.enabled') == 0),
'websrv_avail' => [
'apache2'
],
'advanced_mode' => true
],
'system_http2_support' => [
'label' => lng('serversettings.http2_support'),
'settinggroup' => 'system',
'varname' => 'http2_support',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField',
'websrv_avail' => [
'apache2',
'nginx'
],
'visible' => Settings::Get('system.use_ssl')
],
'system_dhparams_file' => [
'label' => lng('serversettings.dhparams_file'),
'settinggroup' => 'system',
'varname' => 'dhparams_file',
'type' => 'text',
'string_type' => 'file',
'string_emptyallowed' => true,
'default' => '',
'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.use_ssl'),
'advanced_mode' => true
],
'system_httpuser' => [
'label' => lng('admin.webserver_user'),
'settinggroup' => 'system',
'varname' => 'httpuser',
'type' => 'text',
'default' => 'www-data',
'save_method' => 'storeSettingWebserverFcgidFpmUser'
],
'system_httpgroup' => [
'label' => lng('admin.webserver_group'),
'settinggroup' => 'system',
'varname' => 'httpgroup',
'type' => 'text',
'default' => 'www-data',
'save_method' => 'storeSettingField'
],
'system_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' => 'dir',
'default' => '/etc/apache2/htpasswd/', 'default' => '/etc/apache2/htpasswd/',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
], ),
'system_logfiles_directory' => [ 'system_apachereload_command' => array(
'label' => lng('serversettings.logfiles_directory'), 'label' => $lng['serversettings']['apachereload_command'],
'settinggroup' => 'system',
'varname' => 'apachereload_command',
'type' => 'string',
'default' => '/etc/init.d/apache2 reload',
'save_method' => 'storeSettingField',
),
'system_mod_log_sql' => array(
'label' => $lng['serversettings']['mod_log_sql'],
'settinggroup' => 'system',
'varname' => 'mod_log_sql',
'type' => 'bool',
'default' => false,
'save_method' => 'storeSettingField',
),
'system_logfiles_directory' => array(
'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_phpappendopenbasedir' => array(
'system_logfiles_script' => [ 'label' => $lng['serversettings']['phpappendopenbasedir'],
'label' => lng('serversettings.logfiles_script'),
'settinggroup' => 'system',
'varname' => 'logfiles_script',
'type' => 'text',
'default' => '',
'save_method' => 'storeSettingField',
'websrv_avail' => [
'apache2'
],
'advanced_mode' => true
],
'system_logfiles_piped' => [
'label' => lng('serversettings.logfiles_piped'),
'settinggroup' => 'system',
'varname' => 'logfiles_piped',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField',
'websrv_avail' => [
'apache2'
],
'advanced_mode' => true
],
'system_logfiles_format' => [
'label' => lng('serversettings.logfiles_format'),
'settinggroup' => 'system',
'varname' => 'logfiles_format',
'type' => 'text',
'default' => '',
'string_emptyallowed' => true,
'save_method' => 'storeSettingField',
'websrv_avail' => [
'apache2',
'nginx'
],
'visible' => Settings::Get('system.traffictool') != 'webalizer',
'advanced_mode' => true
],
'system_logfiles_type' => [
'label' => lng('serversettings.logfiles_type'),
'settinggroup' => 'system',
'varname' => 'logfiles_type',
'type' => 'select',
'default' => '1',
'select_var' => [
'1' => 'combined',
'2' => 'vhost_combined'
],
'save_method' => 'storeSettingField',
'websrv_avail' => [
'apache2'
]
],
'system_errorlog_level' => [
'label' => lng('serversettings.errorlog_level'),
'settinggroup' => 'system',
'varname' => 'errorlog_level',
'type' => 'select',
'default' => (Settings::Get('system.webserver') == 'nginx' ? 'error' : 'warn'),
'select_var' => [
'emerg' => 'emerg',
'alert' => 'alert',
'crit' => 'crit',
'error' => 'error',
'warn' => 'warn',
'notice' => 'notice',
'info' => 'info',
'debug' => 'debug'
],
'save_method' => 'storeSettingField',
'websrv_avail' => [
'apache2',
'nginx'
]
],
'system_customersslpath' => [
'label' => lng('serversettings.customerssl_directory'),
'settinggroup' => 'system',
'varname' => 'customer_ssl_path',
'type' => 'text',
'string_type' => 'confdir',
'default' => '/etc/ssl/froxlor-custom/',
'save_method' => 'storeSettingField'
],
'system_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' => [ ),
'label' => lng('serversettings.default_sslvhostconf'), 'ssl' => array(
'title' => $lng['admin']['sslsettings'],
'fields' => array(
'system_ssl_enabled' => array(
'label' => $lng['serversettings']['ssl']['use_ssl'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'default_sslvhostconf', 'varname' => 'use_ssl',
'type' => 'textarea', 'type' => 'bool',
'default' => '',
'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.use_ssl') == 1,
'advanced_mode' => true
],
'system_include_default_vhostconf' => [
'label' => lng('serversettings.includedefault_sslvhostconf'),
'settinggroup' => 'system',
'varname' => 'include_default_vhostconf',
'type' => 'checkbox',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'advanced_mode' => true ),
], 'system_ssl_cert_file' => array(
'system_apache_globaldiropt' => [ 'label' => $lng['serversettings']['ssl']['ssl_cert_file'],
'label' => lng('serversettings.apache_globaldiropt'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'apacheglobaldiropt', 'varname' => 'ssl_cert_file',
'type' => 'textarea', 'type' => 'string',
'default' => '',
'save_method' => 'storeSettingField',
'visible' => (Settings::Get('system.mod_fcgid') == 0 && Settings::Get('phpfpm.enabled') == 0),
'websrv_avail' => [
'apache2'
],
'advanced_mode' => true
],
'system_apachereload_command' => [
'label' => lng('serversettings.apachereload_command'),
'settinggroup' => 'system',
'varname' => 'apachereload_command',
'type' => 'text',
'string_regexp' => '/^[a-z0-9\/\._\- ]+$/i',
'default' => '/etc/init.d/apache2 reload',
'save_method' => 'storeSettingField'
],
'system_phpreload_command' => [
'label' => lng('serversettings.phpreload_command'),
'settinggroup' => 'system',
'varname' => 'phpreload_command',
'type' => 'text',
'string_regexp' => '/^[a-z0-9\/\._\- ]+$/i',
'default' => '',
'save_method' => 'storeSettingField',
'websrv_avail' => [
'nginx'
]
],
'system_nginx_php_backend' => [
'label' => lng('serversettings.nginx_php_backend'),
'settinggroup' => 'system',
'varname' => 'nginx_php_backend',
'type' => 'text',
'default' => '127.0.0.1:8888',
'save_method' => 'storeSettingField',
'websrv_avail' => [
'nginx'
]
],
'nginx_fastcgiparams' => [
'label' => lng('serversettings.nginx_fastcgiparams'),
'settinggroup' => 'nginx',
'varname' => 'fastcgiparams',
'type' => 'text',
'string_type' => 'file', 'string_type' => 'file',
'default' => '/etc/nginx/fastcgi_params', 'string_emptyallowed' => true,
'default' => '/etc/apache2/apache2.pem',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => [ ),
'nginx' 'system_ssl_key_file' => array(
] 'label' => $lng['serversettings']['ssl']['ssl_key_file'],
], 'settinggroup' => 'system',
'defaultwebsrverrhandler_enabled' => [ 'varname' => 'ssl_key_file',
'label' => lng('serversettings.defaultwebsrverrhandler_enabled'), 'type' => 'string',
'settinggroup' => 'defaultwebsrverrhandler', 'string_type' => 'file',
'varname' => 'enabled', 'string_emptyallowed' => true,
'type' => 'checkbox', 'default' => '/etc/apache2/apache2.key',
'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'advanced_mode' => true ),
], 'system_ssl_ca_file' => array(
'defaultwebsrverrhandler_err401' => [ 'label' => $lng['serversettings']['ssl']['ssl_ca_file'],
'label' => lng('serversettings.defaultwebsrverrhandler_err401'), 'settinggroup' => 'system',
'settinggroup' => 'defaultwebsrverrhandler', 'varname' => 'ssl_ca_file',
'varname' => 'err401', 'type' => 'string',
'string_type' => 'file',
'string_emptyallowed' => true,
'default' => '',
'save_method' => 'storeSettingField',
),
'system_ssl_openssl_cnf' => array(
'label' => $lng['serversettings']['ssl']['openssl_cnf'],
'settinggroup' => 'system',
'varname' => 'openssl_cnf',
'type' => 'text', 'type' => 'text',
'default' => '', 'default' => '',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => [ ),
'apache2', ),
'nginx' ),
], ),
'advanced_mode' => true );
],
'defaultwebsrverrhandler_err403' => [ ?>
'label' => lng('serversettings.defaultwebsrverrhandler_err403'),
'settinggroup' => 'defaultwebsrverrhandler',
'varname' => 'err403',
'type' => 'text',
'default' => '',
'save_method' => 'storeSettingField',
'websrv_avail' => [
'apache2',
'nginx'
],
'advanced_mode' => true
],
'defaultwebsrverrhandler_err404' => [
'label' => lng('serversettings.defaultwebsrverrhandler_err404'),
'settinggroup' => 'defaultwebsrverrhandler',
'varname' => 'err404',
'type' => 'text',
'default' => '',
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'defaultwebsrverrhandler_err500' => [
'label' => lng('serversettings.defaultwebsrverrhandler_err500'),
'settinggroup' => 'defaultwebsrverrhandler',
'varname' => 'err500',
'type' => 'text',
'default' => '',
'save_method' => 'storeSettingField',
'websrv_avail' => [
'apache2',
'nginx'
],
'advanced_mode' => true
],
'customredirect_enabled' => [
'label' => lng('serversettings.customredirect_enabled'),
'settinggroup' => 'customredirect',
'varname' => 'enabled',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField'
],
'customredirect_default' => [
'label' => lng('serversettings.customredirect_default'),
'settinggroup' => 'customredirect',
'varname' => 'default',
'type' => 'select',
'default' => '1',
'option_options_method' => ['\\Froxlor\\Domain\\Domain', 'getRedirectCodes'],
'save_method' => 'storeSettingField'
]
]
]
]
];

View File

@@ -1,246 +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
*/
use Froxlor\Froxlor;
use Froxlor\Settings;
return [
'groups' => [
'ssl' => [
'title' => lng('admin.sslsettings'),
'icon' => 'fa-solid fa-shield',
'fields' => [
'system_ssl_enabled' => [
'label' => lng('serversettings.ssl.use_ssl'),
'settinggroup' => 'system',
'varname' => 'use_ssl',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField',
'overview_option' => true,
'requires_reconf' => ['http']
],
'system_ssl_protocols' => [
'label' => lng('serversettings.ssl.ssl_protocols'),
'settinggroup' => 'system',
'varname' => 'ssl_protocols',
'type' => 'select',
'default' => 'TLSv1.2',
'select_mode' => 'multiple',
'select_var' => [
'TLSv1' => 'TLSv1',
'TLSv1.1' => 'TLSv1.1',
'TLSv1.2' => 'TLSv1.2',
'TLSv1.3' => 'TLSv1.3'
],
'save_method' => 'storeSettingField'
],
'system_ssl_cipher_list' => [
'label' => lng('serversettings.ssl.ssl_cipher_list'),
'settinggroup' => 'system',
'varname' => 'ssl_cipher_list',
'type' => 'text',
'string_emptyallowed' => false,
'default' => 'ECDH+AESGCM:ECDH+AES256:!aNULL:!MD5:!DSS:!DH:!AES128',
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'system_tlsv13_cipher_list' => [
'label' => lng('serversettings.ssl.tlsv13_cipher_list'),
'settinggroup' => 'system',
'varname' => 'tlsv13_cipher_list',
'type' => 'text',
'string_emptyallowed' => true,
'default' => '',
'visible' => Settings::Get('system.webserver') == "apache2" && Settings::Get('system.apache24') == 1,
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'system_ssl_cert_file' => [
'label' => lng('serversettings.ssl.ssl_cert_file'),
'settinggroup' => 'system',
'varname' => 'ssl_cert_file',
'type' => 'text',
'string_type' => 'file',
'string_emptyallowed' => true,
'default' => '/etc/ssl/froxlor_selfsigned.pem',
'save_method' => 'storeSettingField'
],
'system_ssl_key_file' => [
'label' => lng('serversettings.ssl.ssl_key_file'),
'settinggroup' => 'system',
'varname' => 'ssl_key_file',
'type' => 'text',
'string_type' => 'file',
'string_emptyallowed' => true,
'default' => '/etc/ssl/froxlor_selfsigned.key',
'save_method' => 'storeSettingField'
],
'system_ssl_cert_chainfile' => [
'label' => lng('admin.ipsandports.ssl_cert_chainfile'),
'settinggroup' => 'system',
'varname' => 'ssl_cert_chainfile',
'type' => 'text',
'string_type' => 'file',
'string_emptyallowed' => true,
'default' => '',
'save_method' => 'storeSettingField'
],
'system_ssl_ca_file' => [
'label' => lng('serversettings.ssl.ssl_ca_file'),
'settinggroup' => 'system',
'varname' => 'ssl_ca_file',
'type' => 'text',
'string_type' => 'file',
'string_emptyallowed' => true,
'default' => '',
'save_method' => 'storeSettingField'
],
'system_apache24_ocsp_cache_path' => [
'label' => lng('serversettings.ssl.apache24_ocsp_cache_path'),
'settinggroup' => 'system',
'varname' => 'apache24_ocsp_cache_path',
'type' => 'text',
'string_emptyallowed' => false,
'default' => 'shmcb:/var/run/apache2/ocsp-stapling.cache(131072)',
'visible' => Settings::Get('system.webserver') == "apache2" && Settings::Get('system.apache24') == 1,
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'system_sessionticketsenabled' => [
'label' => lng('admin.domain_sessionticketsenabled'),
'settinggroup' => 'system',
'varname' => 'sessionticketsenabled',
'type' => 'checkbox',
'default' => true,
'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.use_ssl') && (Settings::Get('system.webserver') == "nginx" || (Settings::Get('system.webserver') == "apache2" && Settings::Get('system.apache24') == 1)),
'advanced_mode' => true
],
'system_leenabled' => [
'label' => lng('serversettings.leenabled'),
'settinggroup' => 'system',
'varname' => 'leenabled',
'type' => 'checkbox',
'default' => false,
'cronmodule' => 'froxlor/letsencrypt',
'save_method' => 'storeSettingField',
'requires_reconf' => ['http']
],
'system_acmeshpath' => [
'label' => lng('serversettings.acmeshpath'),
'settinggroup' => 'system',
'varname' => 'acmeshpath',
'type' => 'text',
'string_type' => 'file',
'default' => '/root/.acme.sh/acme.sh',
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'system_letsencryptacmeconf' => [
'label' => lng('serversettings.letsencryptacmeconf'),
'settinggroup' => 'system',
'varname' => 'letsencryptacmeconf',
'type' => 'text',
'string_type' => 'file',
'default' => '/etc/apache2/conf-enabled/acme.conf',
'save_method' => 'storeSettingField',
'requires_reconf' => ['http']
],
'system_letsencryptca' => [
'label' => lng('serversettings.letsencryptca'),
'settinggroup' => 'system',
'varname' => 'letsencryptca',
'type' => 'select',
'default' => 'letsencrypt',
'select_var' => [
'letsencrypt_test' => 'Let\'s Encrypt (Test / Staging)',
'letsencrypt' => 'Let\'s Encrypt (Live)',
'buypass_test' => 'Buypass (Test / Staging)',
'buypass' => 'Buypass (Live)',
'zerossl' => 'ZeroSSL (Live)'
],
'save_method' => 'storeSettingField'
],
'system_letsencryptchallengepath' => [
'label' => lng('serversettings.letsencryptchallengepath'),
'settinggroup' => 'system',
'varname' => 'letsencryptchallengepath',
'type' => 'text',
'string_emptyallowed' => false,
'default' => Froxlor::getInstallDir(),
'save_method' => 'storeSettingField',
'advanced_mode' => true,
'requires_reconf' => ['http']
],
'system_letsencryptkeysize' => [
'label' => lng('serversettings.letsencryptkeysize'),
'settinggroup' => 'system',
'varname' => 'letsencryptkeysize',
'type' => 'select',
'default' => '2048',
'select_var' => [
'2048' => '2048',
'3072' => '3072',
'4096' => '4096',
'8192' => '8192'
],
'save_method' => 'storeSettingField'
],
'system_leecc' => [
'label' => lng('serversettings.letsencryptecc'),
'settinggroup' => 'system',
'varname' => 'leecc',
'type' => 'select',
'default' => '0',
'select_var' => [
'0' => '-',
'256' => 'ec-256',
'384' => 'ec-384'
],
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'system_letsencryptreuseold' => [
'label' => lng('serversettings.letsencryptreuseold'),
'settinggroup' => 'system',
'varname' => 'letsencryptreuseold',
'type' => 'checkbox',
'default' => true,
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'system_le_domain_dnscheck' => [
'label' => lng('serversettings.le_domain_dnscheck'),
'settinggroup' => 'system',
'varname' => 'le_domain_dnscheck',
'type' => 'checkbox',
'default' => true,
'save_method' => 'storeSettingField'
]
]
]
]
];

View File

@@ -1,145 +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
*/
return [
'groups' => [
'fcgid' => [
'title' => lng('admin.fcgid_settings'),
'icon' => 'fa-brands fa-php',
'websrv_avail' => [
'apache2',
'lighttpd'
],
'fields' => [
'system_mod_fcgid_enabled' => [
'label' => lng('serversettings.mod_fcgid'),
'settinggroup' => 'system',
'varname' => 'mod_fcgid',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField',
'plausibility_check_method' => [
'\\Froxlor\\Validate\\Check',
'checkFcgidPhpFpm'
],
'overview_option' => true,
'requires_reconf' => ['http', 'system:fcgid']
],
'system_mod_fcgid_configdir' => [
'label' => lng('serversettings.mod_fcgid.configdir'),
'settinggroup' => 'system',
'varname' => 'mod_fcgid_configdir',
'type' => 'text',
'string_type' => 'confdir',
'default' => '/var/www/php-fcgi-scripts/',
'plausibility_check_method' => [
'\\Froxlor\\Validate\\Check',
'checkPathConflicts'
],
'save_method' => 'storeSettingField',
'requires_reconf' => ['system:fcgid']
],
'system_mod_fcgid_tmpdir' => [
'label' => lng('serversettings.mod_fcgid.tmpdir'),
'settinggroup' => 'system',
'varname' => 'mod_fcgid_tmpdir',
'type' => 'text',
'string_type' => 'dir',
'default' => '/var/customers/tmp/',
'save_method' => 'storeSettingField',
'requires_reconf' => ['http']
],
'system_mod_fcgid_peardir' => [
'label' => lng('serversettings.mod_fcgid.peardir'),
'settinggroup' => 'system',
'varname' => 'mod_fcgid_peardir',
'type' => 'text',
'string_type' => 'dir',
'string_delimiter' => ':',
'string_emptyallowed' => true,
'default' => '/usr/share/php/:/usr/share/php5/',
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'system_mod_fcgid_wrapper' => [
'label' => lng('serversettings.mod_fcgid.wrapper'),
'settinggroup' => 'system',
'varname' => 'mod_fcgid_wrapper',
'type' => 'select',
'select_var' => [
0 => 'ScriptAlias',
1 => 'FcgidWrapper'
],
'default' => 1,
'save_method' => 'storeSettingField',
'websrv_avail' => [
'apache2'
],
'advanced_mode' => true
],
'system_mod_fcgid_starter' => [
'label' => lng('serversettings.mod_fcgid.starter'),
'settinggroup' => 'system',
'varname' => 'mod_fcgid_starter',
'type' => 'number',
'min' => 0,
'default' => 0,
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'system_mod_fcgid_maxrequests' => [
'label' => lng('serversettings.mod_fcgid.maxrequests'),
'settinggroup' => 'system',
'varname' => 'mod_fcgid_maxrequests',
'type' => 'number',
'default' => 250,
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'system_mod_fcgid_defaultini' => [
'label' => lng('serversettings.mod_fcgid.defaultini'),
'settinggroup' => 'system',
'varname' => 'mod_fcgid_defaultini',
'type' => 'select',
'default' => '1',
'option_options_method' => [
'\\Froxlor\\Http\\PhpConfig',
'getPhpConfigs'
],
'save_method' => 'storeSettingField'
],
'system_mod_fcgid_idle_timeout' => [
'label' => lng('serversettings.mod_fcgid.idle_timeout'),
'settinggroup' => 'system',
'varname' => 'mod_fcgid_idle_timeout',
'type' => 'number',
'default' => 30,
'save_method' => 'storeSettingField',
'advanced_mode' => true
]
]
]
]
];

View File

@@ -1,161 +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
*/
use Froxlor\Settings;
return [
'groups' => [
'phpfpm' => [
'title' => lng('admin.phpfpm_settings'),
'icon' => 'fa-brands fa-php',
'fields' => [
'system_phpfpm_enabled' => [
'label' => lng('serversettings.phpfpm'),
'settinggroup' => 'phpfpm',
'varname' => 'enabled',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField',
'plausibility_check_method' => [
'\\Froxlor\\Validate\\Check',
'checkFcgidPhpFpm'
],
'overview_option' => true,
'requires_reconf' => ['http', 'system:php-fpm']
],
'system_phpfpm_defaultini' => [
'label' => lng('serversettings.mod_fcgid.defaultini'),
'settinggroup' => 'phpfpm',
'varname' => 'defaultini',
'type' => 'select',
'default' => '1',
'option_options_method' => [
'\\Froxlor\\Http\\PhpConfig',
'getPhpConfigs'
],
'save_method' => 'storeSettingField'
],
'system_phpfpm_aliasconfigdir' => [
'label' => lng('serversettings.phpfpm_settings.aliasconfigdir'),
'settinggroup' => 'phpfpm',
'varname' => 'aliasconfigdir',
'type' => 'text',
'string_type' => 'confdir',
'default' => '/var/www/php-fpm/',
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'system_phpfpm_tmpdir' => [
'label' => lng('serversettings.mod_fcgid.tmpdir'),
'settinggroup' => 'phpfpm',
'varname' => 'tmpdir',
'type' => 'text',
'string_type' => 'dir',
'default' => '/var/customers/tmp/',
'save_method' => 'storeSettingField'
],
'system_phpfpm_peardir' => [
'label' => lng('serversettings.mod_fcgid.peardir'),
'settinggroup' => 'phpfpm',
'varname' => 'peardir',
'type' => 'text',
'string_type' => 'dir',
'string_delimiter' => ':',
'string_emptyallowed' => true,
'default' => '/usr/share/php/:/usr/share/php5/',
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'system_phpfpm_envpath' => [
'label' => lng('serversettings.phpfpm_settings.envpath'),
'settinggroup' => 'phpfpm',
'varname' => 'envpath',
'type' => 'text',
'string_type' => 'dir',
'string_delimiter' => ':',
'string_emptyallowed' => true,
'default' => '/usr/local/bin:/usr/bin:/bin',
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'system_phpfpm_fastcgi_ipcdir' => [
'label' => lng('serversettings.phpfpm_settings.ipcdir'),
'settinggroup' => 'phpfpm',
'varname' => 'fastcgi_ipcdir',
'type' => 'text',
'string_type' => 'dir',
'default' => '/var/lib/apache2/fastcgi/',
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'system_phpfpm_use_mod_proxy' => [
'label' => lng('phpfpm.use_mod_proxy'),
'settinggroup' => 'phpfpm',
'varname' => 'use_mod_proxy',
'type' => 'checkbox',
'default' => true,
'visible' => Settings::Get('system.apache24'),
'save_method' => 'storeSettingField'
],
'system_phpfpm_ini_flags' => [
'label' => lng('phpfpm.ini_flags'),
'settinggroup' => 'phpfpm',
'varname' => 'ini_flags',
'type' => 'textarea',
'default' => '',
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'system_phpfpm_ini_values' => [
'label' => lng('phpfpm.ini_values'),
'settinggroup' => 'phpfpm',
'varname' => 'ini_values',
'type' => 'textarea',
'default' => '',
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'system_phpfpm_ini_admin_flags' => [
'label' => lng('phpfpm.ini_admin_flags'),
'settinggroup' => 'phpfpm',
'varname' => 'ini_admin_flags',
'type' => 'textarea',
'default' => '',
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'system_phpfpm_ini_admin_values' => [
'label' => lng('phpfpm.ini_admin_values'),
'settinggroup' => 'phpfpm',
'varname' => 'ini_admin_values',
'type' => 'textarea',
'default' => '',
'save_method' => 'storeSettingField',
'advanced_mode' => true
]
]
]
]
];

View File

@@ -1,80 +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
*/
return [
'groups' => [
'perl' => [
'title' => lng('admin.perl_settings'),
'icon' => 'fa-solid fa-code',
'fields' => [
'perl_path' => [
'label' => lng('serversettings.perl_path'),
'settinggroup' => 'system',
'varname' => 'perl_path',
'type' => 'text',
'default' => '/usr/bin/perl',
'save_method' => 'storeSettingField',
'websrv_avail' => [
'lighttpd'
]
],
'system_perl_suexecworkaround' => [
'label' => lng('serversettings.perl.suexecworkaround'),
'settinggroup' => 'perl',
'varname' => 'suexecworkaround',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField',
'websrv_avail' => [
'apache2'
]
],
'system_perl_suexeccgipath' => [
'label' => lng('serversettings.perl.suexeccgipath'),
'settinggroup' => 'perl',
'varname' => 'suexecpath',
'type' => 'text',
'string_type' => 'dir',
'default' => '/var/www/cgi-bin/',
'save_method' => 'storeSettingField',
'websrv_avail' => [
'apache2'
]
],
'perl_server' => [
'label' => lng('serversettings.perl_server'),
'settinggroup' => 'serversettings',
'varname' => 'perl_server',
'type' => 'text',
'default' => 'unix:/var/run/nginx/cgiwrap-dispatch.sock',
'save_method' => 'storeSettingField',
'websrv_avail' => [
'nginx'
]
]
]
]
]
];

View File

@@ -2,115 +2,83 @@
/** /**
* 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 * @version $Id$
* 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\Settings; return array(
'groups' => array(
return [ 'statistics' => array(
'groups' => [ 'title' => $lng['admin']['statisticsettings'],
'statistics' => [ 'fields' => array(
'title' => lng('admin.statisticsettings'), 'system_webalizer_quiet' => array(
'icon' => 'fa-solid fa-chart-area', 'label' => $lng['serversettings']['webalizer_quiet'],
'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(0 => $lng['admin']['webalizer']['normal'], 1 => $lng['admin']['webalizer']['quiet'], 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' ),
], 'system_awstats_enabled' => array(
'system_awstats_path' => [ 'label' => $lng['serversettings']['awstats_enabled'],
'label' => lng('serversettings.awstats_path'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'awstats_path', 'varname' => 'awstats_enabled',
'type' => 'text', 'type' => 'bool',
'string_type' => 'dir', 'default' => false,
'default' => '/usr/share/awstats/tools/',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.traffictool') == 'awstats' ),
], 'system_awstats_domain_file' => array(
'system_awstats_awstatspath' => [ 'label' => $lng['serversettings']['awstats_domain_file'],
'label' => lng('serversettings.awstats_awstatspath'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'awstats_awstatspath', 'varname' => 'awstats_domain_file',
'type' => 'text', 'type' => 'string',
'string_type' => 'dir',
'default' => '/usr/lib/cgi-bin/',
'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.traffictool') == 'awstats'
],
'system_awstats_conf' => [
'label' => lng('serversettings.awstats_conf'),
'settinggroup' => 'system',
'varname' => 'awstats_conf',
'type' => 'text',
'string_type' => 'dir', 'string_type' => 'dir',
'default' => '/etc/awstats/', 'default' => '/etc/awstats/',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.traffictool') == 'awstats', ),
'requires_reconf' => ['system:awstats'] 'system_awstats_model_file' => array(
], 'label' => $lng['serversettings']['awstats_model_file'],
'system_awstats_icons' => [
'label' => lng('serversettings.awstats_icons'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'awstats_icons', 'varname' => 'awstats_model_file',
'type' => 'text', 'type' => 'string',
'string_type' => 'file',
'default' => '/etc/awstats/awstats.model.conf.syscp',
'save_method' => 'storeSettingField',
),
'system_awstats_path' => array(
'label' => $lng['serversettings']['awstats_path'],
'settinggroup' => 'system',
'varname' => 'awstats_path',
'type' => 'string',
'string_type' => 'dir', 'string_type' => 'dir',
'default' => '/usr/share/awstats/icon/', 'default' => '/usr/share/awstats/VERSION/webroot/cgi-bin/',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.traffictool') == 'awstats' ),
], 'system_awstats_updateall_command' => array(
'system_awstats_logformat' => [ 'label' => $lng['serversettings']['awstats_updateall_command'],
'label' => lng('serversettings.awstats.logformat'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'awstats_logformat', 'varname' => 'awstats_updateall_command',
'type' => 'text', 'type' => 'string',
'default' => '1', 'string_type' => 'file',
'default' => '/usr/bin/awstats_updateall.pl',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => Settings::Get('system.traffictool') == 'awstats', ),
'advanced_mode' => true ),
] ),
] ),
] );
]
]; ?>

View File

@@ -2,168 +2,97 @@
/** /**
* 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 * @version $Id$
* 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 [ return array(
'groups' => [ 'groups' => array(
'mail' => [ 'mail' => array(
'title' => lng('admin.mailserversettings'), 'title' => $lng['admin']['mailserversettings'],
'icon' => 'fa-solid fa-envelope', 'fields' => array(
'fields' => [ 'system_vmail_uid' => array(
'system_vmail_uid' => [ 'label' => $lng['serversettings']['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'] ),
], 'panel_sendalternativemail' => array(
'system_vmail_maildirname' => [ 'label' => $lng['serversettings']['sendalternativemail'],
'label' => lng('serversettings.vmail_maildirname'),
'settinggroup' => 'system',
'varname' => 'vmail_maildirname',
'type' => 'text',
'string_type' => 'dir',
'default' => 'Maildir',
'string_emptyallowed' => true,
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'panel_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'
],
'system_catchall_enabled' => [
'label' => lng('serversettings.catchall_enabled'),
'settinggroup' => 'catchall',
'varname' => 'catchall_enabled',
'type' => 'checkbox',
'default' => true,
'save_method' => 'storeSettingResetCatchall'
],
'system_mailtraffic_enabled' => [
'label' => lng('serversettings.mailtraffic_enabled'),
'settinggroup' => 'system',
'varname' => 'mailtraffic_enabled',
'type' => 'checkbox',
'default' => true,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'advanced_mode' => true ),
], 'systen_autoresponder_enabled' => array(
'system_mdaserver' => [ 'label' => $lng['serversettings']['autoresponder_active'],
'label' => lng('serversettings.mdaserver'), 'settinggroup' => 'autoresponder',
'settinggroup' => 'system', 'varname' => 'autoresponder_active',
'varname' => 'mdaserver', 'type' => 'bool',
'type' => 'select', 'default' => false,
'default' => 'dovecot', 'cronmodule' => 'froxlor/autoresponder',
'select_var' => [
'courier' => 'Courier',
'dovecot' => 'Dovecot'
],
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'advanced_mode' => true ),
], 'systen_last_autoresponder_run' => array(
'system_mdalog' => [ 'settinggroup' => 'autoresponder',
'label' => lng('serversettings.mdalog'), 'varname' => 'last_autoresponder_run',
'settinggroup' => 'system', 'type' => 'hidden',
'varname' => 'mdalog', 'default' => 0,
'type' => 'text', ),
'string_type' => 'file', ),
'default' => '/var/log/mail.log', ),
'string_emptyallowed' => true, ),
'save_method' => 'storeSettingField', );
'advanced_mode' => true
], ?>
'system_mtaserver' => [
'label' => lng('serversettings.mtaserver'),
'settinggroup' => 'system',
'varname' => 'mtaserver',
'type' => 'select',
'default' => 'postfix',
'select_var' => [
'exim4' => 'Exim4',
'postfix' => 'Postfix'
],
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'system_mtalog' => [
'label' => lng('serversettings.mtalog'),
'settinggroup' => 'system',
'varname' => 'mtalog',
'type' => 'text',
'string_type' => 'file',
'default' => '/var/log/mail.log',
'string_emptyallowed' => true,
'save_method' => 'storeSettingField',
'advanced_mode' => true
]
]
]
]
];

View File

@@ -1,47 +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
*/
return [
'groups' => [
'ftpserver' => [
'title' => lng('admin.ftpserversettings'),
'icon' => 'fa-solid fa-arrow-right-arrow-left',
'fields' => [
'ftpserver' => [
'label' => lng('admin.ftpserver'),
'settinggroup' => 'system',
'varname' => 'ftpserver',
'type' => 'select',
'default' => 'proftpd',
'select_var' => [
'proftpd' => 'Proftpd',
'pureftpd' => 'Pureftpd'
],
'save_method' => 'storeSettingField'
]
]
]
]
];

View File

@@ -2,177 +2,66 @@
/** /**
* 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 * @version $Id$
* 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\Settings; return array(
'groups' => array(
return [ 'nameserver' => array(
'groups' => [ 'title' => $lng['admin']['nameserversettings'],
'nameserver' => [ 'fields' => array(
'title' => lng('admin.nameserversettings'), 'system_bindconf_directory' => array(
'icon' => 'fa-solid fa-globe', 'label' => $lng['serversettings']['bindconf_directory'],
'fields' => [
'nameserver_enable' => [
'label' => lng('serversettings.bindenable'),
'settinggroup' => 'system',
'varname' => 'bind_enable',
'type' => 'checkbox',
'default' => true,
'save_method' => 'storeSettingField',
'overview_option' => true,
'requires_reconf' => ['dns']
],
'system_dnsenabled' => [
'label' => lng('serversettings.dnseditorenable'),
'settinggroup' => 'system',
'varname' => 'dnsenabled',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField'
],
'system_dns_server' => [
'label' => lng('serversettings.dns_server'),
'settinggroup' => 'system',
'varname' => 'dns_server',
'type' => 'select',
'default' => 'Bind',
'select_var' => [
'Bind' => 'Bind9',
'PowerDNS' => 'PowerDNS'
],
'save_method' => 'storeSettingField',
'requires_reconf' => ['dns']
],
'system_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'
],
'system_axfrservers' => [
'label' => lng('serversettings.axfrservers'),
'settinggroup' => 'system',
'varname' => 'axfrservers',
'type' => 'text',
'string_type' => 'validate_ip_incl_private',
'string_delimiter' => ',',
'string_emptyallowed' => true,
'default' => '',
'save_method' => 'storeSettingField'
],
'system_powerdns_mode' => [
'label' => lng('serversettings.powerdns_mode'),
'settinggroup' => 'system',
'varname' => 'powerdns_mode',
'type' => 'select',
'default' => 'Native',
'select_var' => [
'Native' => 'Native',
'Master' => 'Master'
],
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'advanced_mode' => true, ),
'visible' => Settings::Get('system.dns_server') == 'PowerDNS', ),
], ),
'system_dns_createmailentry' => [ ),
'label' => lng('serversettings.mail_also_with_mxservers'), );
'settinggroup' => 'system',
'varname' => 'dns_createmailentry', ?>
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField'
],
'system_dns_createcaaentry' => [
'label' => lng('serversettings.caa_entry'),
'settinggroup' => 'system',
'varname' => 'dns_createcaaentry',
'type' => 'checkbox',
'default' => true,
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'caa_caa_entry' => [
'label' => lng('serversettings.caa_entry_custom'),
'settinggroup' => 'caa',
'varname' => 'caa_entry',
'type' => 'textarea',
'default' => '',
'save_method' => 'storeSettingField',
'advanced_mode' => true
],
'system_defaultttl' => [
'label' => lng('serversettings.defaultttl'),
'settinggroup' => 'system',
'varname' => 'defaultttl',
'type' => 'number',
'default' => 604800, /* 1 week */
'min' => 3600, /* 1 hour */
'max' => 2147483647, /* integer max */
'save_method' => 'storeSettingField'
],
'system_soaemail' => [
'label' => lng('serversettings.soaemail'),
'settinggroup' => 'system',
'varname' => 'soaemail',
'type' => 'email',
'string_emptyallowed' => true,
'default' => '',
'save_method' => 'storeSettingField'
]
]
]
]
];

View File

@@ -2,92 +2,75 @@
/** /**
* 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 * @version $Id$
* 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 [ return array(
'groups' => [ 'groups' => array(
'logging' => [ 'logging' => array(
'title' => lng('admin.loggersettings'), 'title' => $lng['admin']['loggersettings'],
'icon' => 'fa-solid fa-file-lines', 'fields' => array(
'fields' => [ 'logger_enabled' => array(
'logger_enabled' => [ 'label' => $lng['serversettings']['logger']['enable'],
'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 ),
], 'logger_severity' => array(
'logger_severity' => [ '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(1 => $lng['admin']['logger']['normal'], 2 => $lng['admin']['logger']['paranoid']),
2 => lng('admin.logger.paranoid') 'save_method' => 'storeSettingField',
], ),
'save_method' => 'storeSettingField' 'logger_logtypes' => array(
], 'label' => $lng['serversettings']['logger']['types'],
'logger_logtypes' => [
'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', 'file' => 'file', 'mysql' => 'mysql'),
'syslog' => 'syslog', 'save_method' => 'storeSettingField',
'file' => 'file', ),
'mysql' => 'mysql' 'logger_logfile' => array(
], 'label' => $lng['serversettings']['logger']['logfile'],
'save_method' => 'storeSettingField'
],
'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' => 'bool',
'default' => 0, 'default' => false,
'select_var' => [ 'save_method' => 'storeSettingField',
0 => lng('serversettings.logger.logcronoption.never'), ),
1 => lng('serversettings.logger.logcronoption.once'), ),
2 => lng('serversettings.logger.logcronoption.always') ),
], )
'save_method' => 'storeSettingField' );
]
] ?>
]
]
];

View File

@@ -2,144 +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 Settings
* You should have received a copy of the GNU General Public License * @version $Id$
* 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\Settings; return array(
'groups' => array(
return [ 'dkim' => array(
'groups' => [ 'title' => $lng['admin']['dkimsettings'],
'dkim' => [ 'fields' => array(
'title' => lng('admin.dkimsettings'), 'dkim_enabled' => array(
'icon' => 'fa-solid fa-fingerprint', 'label' => $lng['dkim']['use_dkim'],
'fields' => [
'dkim_enabled' => [
'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' => 'storeSettingField',
'overview_option' => true ),
], 'dkim_prefix' => array(
'dkim_prefix' => [ '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',
'default' => '/etc/postfix/dkim/', 'default' => '/etc/postfix/dkim/',
'save_method' => 'storeSettingField'
],
'dkim_privkeysuffix' => [
'label' => lng('dkim.privkeysuffix'),
'settinggroup' => 'dkim',
'varname' => 'privkeysuffix',
'type' => 'text',
'string_regexp' => '/^[a-z0-9\._]+$/i',
'default' => '.priv',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'advanced_mode' => true ),
], 'dkim_domains' => array(
'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_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_algorithm' => [ 'dkimrestart_command' => array(
'label' => lng('dkim.dkim_algorithm'), 'label' => $lng['dkim']['dkimrestart_command'],
'settinggroup' => 'dkim',
'varname' => 'dkim_algorithm',
'type' => 'select',
'default' => 'all',
'select_mode' => 'multiple',
'select_var' => [
'all' => 'All',
'sha1' => 'SHA1',
'sha256' => 'SHA256'
],
'save_method' => 'storeSettingFieldInsertBindTask',
'advanced_mode' => true
],
'dkim_servicetype' => [
'label' => lng('dkim.dkim_servicetype'),
'settinggroup' => 'dkim',
'varname' => 'dkim_servicetype',
'type' => 'select',
'default' => '0',
'select_var' => [
'0' => 'All',
'1' => 'E-Mail'
],
'save_method' => 'storeSettingFieldInsertBindTask',
'advanced_mode' => true
],
'dkim_keylength' => [
'label' => [
'title' => lng('dkim.dkim_keylength.title'),
'description' => lng('dkim.dkim_keylength.description', [Settings::Get('dkim.dkim_prefix')])
],
'settinggroup' => 'dkim',
'varname' => 'dkim_keylength',
'type' => 'select',
'default' => '1024',
'select_var' => [
'1024' => '1024 Bit',
'2048' => '2048 Bit'
],
'save_method' => 'storeSettingFieldInsertBindTask'
],
'dkim_notes' => [
'label' => lng('dkim.dkim_notes'),
'settinggroup' => 'dkim',
'varname' => 'dkim_notes',
'type' => 'text',
'string_regexp' => '/^[a-z0-9\._]+$/i',
'default' => '',
'save_method' => 'storeSettingFieldInsertBindTask',
'advanced_mode' => true
],
'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
* * @version $Id$
* 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 [ return array(
'groups' => [ 'groups' => array(
'spf' => [ 'spf' => array(
'title' => lng('admin.spfsettings'), 'title' => $lng['admin']['spfsettings'],
'icon' => 'fa-solid fa-clipboard-check', 'fields' => array(
'fields' => [ 'spf_enabled' => array(
'use_spf' => [ 'label' => $lng['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 ),
], 'spf_entry' => array(
'spf_entry' => [ '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' => '@ IN TXT "v=spf1 a mx -all"',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
] )
] )
] )
] )
]; );
?>

View File

@@ -0,0 +1,132 @@
<?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 Settings
* @version $Id$
*/
return array(
'groups' => array(
'ticket' => array(
'title' => $lng['admin']['ticketsettings'],
'fields' => array(
'ticket_enabled' => array(
'label' => $lng['serversettings']['ticket']['enable'],
'settinggroup' => 'ticket',
'varname' => 'enabled',
'type' => 'bool',
'default' => false,
'cronmodule' => 'froxlor/ticket',
'save_method' => 'storeSettingField',
),
'ticket_noreply_email' => array(
'label' => $lng['serversettings']['ticket']['noreply_email'],
'settinggroup' => 'ticket',
'varname' => 'noreply_email',
'type' => 'string',
'string_type' => 'mail',
'default' => '',
'save_method' => 'storeSettingField',
),
'ticket_noreply_name' => array(
'label' => $lng['serversettings']['ticket']['noreply_name'],
'settinggroup' => 'ticket',
'varname' => 'noreply_name',
'type' => 'string',
'default' => '',
'save_method' => 'storeSettingField',
),
'ticket_reset_cycle' => array(
'label' => $lng['serversettings']['ticket']['reset_cycle'],
'settinggroup' => 'ticket',
'varname' => 'reset_cycle',
'type' => 'option',
'default' => 1,
'option_mode' => 'one',
'option_options' => array(0 => html_entity_decode($lng['admin']['tickets']['daily']), 1 => html_entity_decode($lng['admin']['tickets']['weekly']), 2 => html_entity_decode($lng['admin']['tickets']['monthly']), 3 => html_entity_decode($lng['admin']['tickets']['yearly'])),
'save_method' => 'storeSettingField',
),
'ticket_concurrently_open' => array(
'label' => $lng['serversettings']['ticket']['concurrentlyopen'],
'settinggroup' => 'ticket',
'varname' => 'concurrently_open',
'type' => 'int',
'default' => 5,
'save_method' => 'storeSettingField',
),
'ticket_archiving_days' => array(
'label' => $lng['serversettings']['ticket']['archiving_days'],
'settinggroup' => 'ticket',
'varname' => 'archiving_days',
'type' => 'int',
'int_min' => 1,
'int_max' => 99,
'default' => 5,
'save_method' => 'storeSettingField',
),
'ticket_worktime_all' => array(
'label' => $lng['serversettings']['ticket']['worktime_all'],
'settinggroup' => 'ticket',
'varname' => 'worktime_all',
'type' => 'bool',
'default' => false,
'save_method' => 'storeSettingField',
),
'ticket_worktime_begin' => array(
'label' => $lng['serversettings']['ticket']['worktime_begin'],
'settinggroup' => 'ticket',
'varname' => 'worktime_begin',
'type' => 'string',
'string_regexp' => '/^[012][0-9]:[0-6][0-9]$/',
'default' => '',
'save_method' => 'storeSettingField',
),
'ticket_worktime_end' => array(
'label' => $lng['serversettings']['ticket']['worktime_end'],
'settinggroup' => 'ticket',
'varname' => 'worktime_end',
'type' => 'string',
'string_regexp' => '/^[012][0-9]:[0-6][0-9]$/',
'default' => '',
'save_method' => 'storeSettingField',
),
'ticket_worktime_sat' => array(
'label' => $lng['serversettings']['ticket']['worktime_sat'],
'settinggroup' => 'ticket',
'varname' => 'worktime_sat',
'type' => 'bool',
'default' => false,
'save_method' => 'storeSettingField',
),
'ticket_worktime_sun' => array(
'label' => $lng['serversettings']['ticket']['worktime_sun'],
'settinggroup' => 'ticket',
'varname' => 'worktime_sun',
'type' => 'bool',
'default' => false,
'save_method' => 'storeSettingField',
),
'system_last_archive_run' => array(
'settinggroup' => 'system',
'varname' => 'last_archive_run',
'type' => 'hidden',
'default' => '',
),
),
),
)
);
?>

View File

@@ -0,0 +1,101 @@
<?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 Settings
* @version $Id$
*/
return array(
'groups' => array(
'aps' => array(
'title' => $lng['admin']['aps'],
'fields' => array(
'aps_enable' => array(
'label' => $lng['aps']['activate_aps'],
'settinggroup' => 'aps',
'varname' => 'aps_active',
'type' => 'bool',
'default' => false,
'cronmodule' => 'froxlor/aps',
'save_method' => 'storeSettingField',
),
'aps_items_per_page' => array(
'label' => $lng['aps']['packages_per_page'],
'settinggroup' => 'aps',
'varname' => 'items_per_page',
'type' => 'int',
'default' => 20,
'save_method' => 'storeSettingField',
),
'aps_upload_fields' => array(
'label' => $lng['aps']['upload_fields'],
'settinggroup' => 'aps',
'varname' => 'upload_fields',
'type' => 'int',
'default' => 5,
'save_method' => 'storeSettingField',
),
'aps_exceptions' => array(
'label' => $lng['aps']['exceptions'],
'type' => 'label',
),
'aps_php-extension' => array(
'label' => $lng['aps']['settings_php_extensions'],
'settinggroup' => 'aps',
'varname' => 'php-extension',
'type' => 'option',
'default' => '',
'option_mode' => 'multiple',
'option_options' => array('gd' => 'GD Library', 'pcre' => 'PCRE', 'ioncube' => 'ionCube', 'ioncube loader' => 'ionCube Loader', 'curl' => 'curl', 'mcrypt' => 'mcrypt', 'imap' => 'imap'),
'save_method' => 'storeSettingApsPhpExtensions',
),
'aps_php-function' => array(
'settinggroup' => 'aps',
'varname' => 'php-function',
'type' => 'hidden',
'default' => '',
),
'aps_php-configuration' => array(
'label' => $lng['aps']['settings_php_configuration'],
'settinggroup' => 'aps',
'varname' => 'php-configuration',
'type' => 'option',
'default' => '',
'option_mode' => 'multiple',
'option_options' => array('short_open_tag' => 'short_open_tag', 'file_uploads' => 'file_uploads', 'magic_quotes_gpc' => 'magic_quotes_gpc', 'register_globals' => 'register_globals', 'allow_url_fopen' => 'allow_url_fopen', 'safe_mode' => 'safe_mode', 'post_max_size' => 'post_max_size', 'memory_limit' => 'memory_limit', 'max_execution_time' => 'max_execution_time'),
'save_method' => 'storeSettingField',
),
'aps_webserver-module' => array(
'label' => $lng['aps']['settings_webserver_modules'],
'settinggroup' => 'aps',
'varname' => 'webserver-module',
'type' => 'option',
'default' => '',
'option_mode' => 'multiple',
'option_options' => array('mod_perl' => 'mod_perl', 'mod_rewrite' => 'mod_rewrite', 'mod_access' => 'mod_access', 'fcgid-any' => 'FastCGI/mod_fcgid', 'htaccess' => '.htaccess'),
'save_method' => 'storeSettingApsWebserverModules',
),
'aps_webserver-htaccess' => array(
'settinggroup' => 'aps',
'varname' => 'webserver-htaccess',
'type' => 'hidden',
'default' => '',
),
),
),
),
);
?>

View File

@@ -2,115 +2,107 @@
/** /**
* 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 * @version $Id$
* 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\Settings; return array(
'groups' => array(
return [ 'security' => array(
'groups' => [ 'title' => $lng['admin']['security_settings'],
'security' => [ 'fields' => array(
'title' => lng('admin.security_settings'), 'panel_unix_names' => array(
'icon' => 'fa-solid fa-user-lock', 'label' => $lng['serversettings']['unix_names'],
'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' => true,
'save_method' => 'storeSettingField',
),
'system_mod_fcgid_enabled' => array(
'label' => $lng['serversettings']['mod_fcgid'],
'settinggroup' => 'system',
'varname' => 'mod_fcgid',
'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'advanced_mode' => true ),
], 'system_mod_fcgid_configdir' => array(
'system_passwordcryptfunc' => [ 'label' => $lng['serversettings']['mod_fcgid']['configdir'],
'label' => lng('serversettings.passwordcryptfunc'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'passwordcryptfunc', 'varname' => 'mod_fcgid_configdir',
'type' => 'select', 'type' => 'string',
'default' => PASSWORD_DEFAULT, 'string_type' => 'dir',
'option_options_method' => [ 'default' => '/var/www/php-fcgi-scripts/',
'\\Froxlor\\System\\Crypt',
'getAvailablePasswordHashes'
],
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'advanced_mode' => true ),
], 'system_mod_fcgid_tmpdir' => array(
'system_allow_error_report_admin' => [ 'label' => $lng['serversettings']['mod_fcgid']['tmpdir'],
'label' => lng('serversettings.allow_error_report_admin'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'allow_error_report_admin', 'varname' => 'mod_fcgid_tmpdir',
'type' => 'checkbox', 'type' => 'string',
'default' => false, 'string_type' => 'dir',
'save_method' => 'storeSettingField' 'default' => '/var/customers/tmp/',
],
'system_allow_error_report_customer' => [
'label' => lng('serversettings.allow_error_report_customer'),
'settinggroup' => 'system',
'varname' => 'allow_error_report_customer',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField'
],
'system_allow_customer_shell' => [
'label' => lng('serversettings.allow_allow_customer_shell'),
'settinggroup' => 'system',
'varname' => 'allow_customer_shell',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'advanced_mode' => true ),
], 'system_mod_fcgid_peardir' => array(
'system_available_shells' => [ 'label' => $lng['serversettings']['mod_fcgid']['peardir'],
'label' => lng('serversettings.available_shells'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'available_shells', 'varname' => 'mod_fcgid_peardir',
'type' => 'text', 'type' => 'string',
'string_type' => 'dir',
'string_delimiter' => ':',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '/usr/share/php/:/usr/share/php5/',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'advanced_mode' => true ),
], 'system_mod_fcgid_wrapper' => array(
'system_froxlorusergroup' => [ 'label' => $lng['serversettings']['mod_fcgid']['wrapper'],
'label' => lng('serversettings.froxlorusergroup'),
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'froxlorusergroup', 'varname' => 'mod_fcgid_wrapper',
'type' => 'text', 'type' => 'option',
'default' => '', 'option_options' => array(0 => 'ScriptAlias', 1=> 'FCGIWrapper'),
'default' => 0,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'plausibility_check_method' => [ ),
'\\Froxlor\\Validate\\Check', 'system_mod_fcgid_starter' => array(
'checkLocalGroup' 'label' => $lng['serversettings']['mod_fcgid']['starter'],
], 'settinggroup' => 'system',
'visible' => Settings::Get('system.nssextrausers'), 'varname' => 'mod_fcgid_starter',
'advanced_mode' => true 'type' => 'int',
], 'default' => 0,
] 'save_method' => 'storeSettingField',
] ),
] 'system_mod_fcgid_maxrequests' => array(
]; 'label' => $lng['serversettings']['mod_fcgid']['maxrequests'],
'settinggroup' => 'system',
'varname' => 'mod_fcgid_maxrequests',
'type' => 'int',
'default' => 250,
'save_method' => 'storeSettingField',
),
),
),
),
);
?>

View File

@@ -1,69 +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
*/
return [
'groups' => [
'diskquota' => [
'title' => lng('diskquota'),
'icon' => 'fa-solid fa-sliders',
'advanced_mode' => true,
'fields' => [
'diskquota_enabled' => [
'label' => lng('serversettings.diskquota_enabled'),
'settinggroup' => 'system',
'varname' => 'diskquota_enabled',
'type' => 'checkbox',
'default' => false,
'save_method' => 'storeSettingField',
'overview_option' => true
],
'diskquota_repquota_path' => [
'label' => lng('serversettings.diskquota_repquota_path.description'),
'settinggroup' => 'system',
'varname' => 'diskquota_repquota_path',
'type' => 'text',
'default' => '/usr/sbin/repquota',
'save_method' => 'storeSettingField'
],
'diskquota_quotatool_path' => [
'label' => lng('serversettings.diskquota_quotatool_path.description'),
'settinggroup' => 'system',
'varname' => 'diskquota_quotatool_path',
'type' => 'text',
'default' => '/usr/bin/quotatool',
'save_method' => 'storeSettingField'
],
'diskquota_customer_partition' => [
'label' => lng('serversettings.diskquota_customer_partition.description'),
'settinggroup' => 'system',
'varname' => 'diskquota_customer_partition',
'type' => 'text',
'default' => '/dev/root',
'save_method' => 'storeSettingField'
]
]
]
]
];

View File

View File

@@ -2,196 +2,739 @@
/** /**
* 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 * @version $Id$
* 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'; define('AREA', 'admin');
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\Admins; /**
use Froxlor\CurrentUser; * Include our init.php, which manages Sessions, Language etc.
use Froxlor\Database\Database; */
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;
$id = (int)Request::any('id'); require ("./lib/init.php");
if (($page == 'admins' || $page == 'overview') && $userinfo['change_serversettings'] == '1') { if(isset($_POST['id']))
if ($action == '') { {
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_admins"); $id = intval($_POST['id']);
}
elseif(isset($_GET['id']))
{
$id = intval($_GET['id']);
}
try { if($page == 'admins'
$admin_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.admins.php'; && $userinfo['change_serversettings'] == '1')
$collection = (new Collection(Admins::class, $userinfo)) {
->withPagination($admin_list_data['admin_list']['columns'], $admin_list_data['admin_list']['default_sorting']); if($action == '')
} catch (Exception $e) { {
Response::dynamicError($e->getMessage()); $log->logAction(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'] . ')',
'mysqls' => $lng['customer']['mysqls'],
'mysqls_used' => $lng['customer']['mysqls'] . ' (' . $lng['panel']['used'] . ')',
'ftps' => $lng['customer']['ftps'],
'ftps_used' => $lng['customer']['ftps'] . ' (' . $lng['panel']['used'] . ')',
'tickets' => $lng['customer']['tickets'],
'tickets_used' => $lng['customer']['tickets'] . ' (' . $lng['panel']['used'] . ')',
'subdomains' => $lng['customer']['subdomains'],
'subdomains_used' => $lng['customer']['subdomains'] . ' (' . $lng['panel']['used'] . ')',
'emails' => $lng['customer']['emails'],
'emails_used' => $lng['customer']['emails'] . ' (' . $lng['panel']['used'] . ')',
'email_accounts' => $lng['customer']['accounts'],
'email_accounts_used' => $lng['customer']['accounts'] . ' (' . $lng['panel']['used'] . ')',
'email_forwarders' => $lng['customer']['forwarders'],
'email_forwarders_used' => $lng['customer']['forwarders'] . ' (' . $lng['panel']['used'] . ')',
'email_quota' => $lng['customer']['email_quota'],
'email_quota_used' => $lng['customer']['email_quota'] . ' (' . $lng['panel']['used'] . ')',
'deactivated' => $lng['admin']['deactivated']
);
$paging = new paging($userinfo, $db, TABLE_PANEL_ADMINS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
$admins = '';
$result = $db->query("SELECT * FROM `" . TABLE_PANEL_ADMINS . "` " . $paging->getSqlWhere(false) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
$paging->setEntries($db->num_rows($result));
$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);
$i = 0;
$count = 0;
while($row = $db->fetch_array($result))
{
if($paging->checkDisplay($i))
{
$row['traffic_used'] = round($row['traffic_used'] / (1024 * 1024), $settings['panel']['decimal_places']);
$row['traffic'] = round($row['traffic'] / (1024 * 1024), $settings['panel']['decimal_places']);
$row['diskspace_used'] = round($row['diskspace_used'] / 1024, $settings['panel']['decimal_places']);
$row['diskspace'] = round($row['diskspace'] / 1024, $settings['panel']['decimal_places']);
$row = str_replace_array('-1', 'UL', $row, 'customers domains diskspace traffic mysqls emails email_accounts email_forwarders email_quota ftps subdomains tickets');
$row = htmlentities_array($row);
eval("\$admins.=\"" . getTemplate("admins/admins_admin") . "\";");
$count++;
}
$i++;
} }
UI::view('user/table.html.twig', [ eval("echo \"" . getTemplate("admins/admins") . "\";");
'listing' => Listing::format($collection, $admin_list_data, 'admin_list'), }
'actions_links' => [ elseif($action == 'su')
[ {
'href' => $linker->getLink(['section' => 'admins', 'page' => $page, 'action' => 'add']), $result = $db->query_first("SELECT * FROM `" . TABLE_PANEL_ADMINS . "` WHERE `adminid` = '" . (int)$id . "'");
'label' => lng('admin.admin_add')
]
]
]);
} elseif ($action == 'su') {
try {
$json_result = Admins::getLocal($userinfo, [
'id' => $id
])->get();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
$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['switched_user'] = CurrentUser::getData(); && $result['adminid'] != $userinfo['userid'])
$result['adminsession'] = 1; {
$result['userid'] = $result['adminid']; $result = $db->query_first("SELECT * FROM `" . TABLE_PANEL_SESSIONS . "` WHERE `userid`='" . (int)$userinfo['userid'] . "'");
CurrentUser::setData($result); $s = md5(uniqid(microtime(), 1));
$db->query("INSERT INTO `" . TABLE_PANEL_SESSIONS . "` (`hash`, `userid`, `ipaddress`, `useragent`, `lastactivity`, `language`, `adminsession`) VALUES ('" . $db->escape($s) . "', '" . (int)$id . "', '" . $db->escape($result['ipaddress']) . "', '" . $db->escape($result['useragent']) . "', '" . time() . "', '" . $db->escape($result['language']) . "', '1')");
$log->logAction( $log->logAction(ADM_ACTION, LOG_INFO, "switched adminuser and is now '" . $destination_admin . "'");
FroxlorLogger::ADM_ACTION, redirectTo('admin_index.php', Array('s' => $s));
LOG_INFO,
"switched adminuser and is now '" . $destination_admin . "'"
);
Response::redirectTo('admin_index.php');
} else {
Response::redirectTo('index.php', [
'action' => 'login'
]);
} }
} elseif ($action == 'delete' && $id != 0) { else
try { {
$json_result = Admins::getLocal($userinfo, [ redirectTo('index.php', Array('action' => 'login'));
'id' => $id
])->get();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; }
elseif($action == 'delete'
&& $id != 0)
{
$result = $db->query_first("SELECT * FROM `" . TABLE_PANEL_ADMINS . "` WHERE `adminid`='" . (int)$id . "'");
if ($result['loginname'] != '') { if($result['loginname'] != '')
if ($result['adminid'] == $userinfo['userid']) { {
Response::standardError('youcantdeleteyourself'); if($result['adminid'] == $userinfo['userid'])
{
standard_error('youcantdeleteyourself');
exit;
} }
if (isset($_POST['send']) && $_POST['send'] == 'send') { if(isset($_POST['send'])
Admins::getLocal($userinfo, [ && $_POST['send'] == 'send')
'id' => $id {
])->delete(); $db->query("DELETE FROM `" . TABLE_PANEL_ADMINS . "` WHERE `adminid`='" . (int)$id . "'");
Response::redirectTo($filename, [ $db->query("DELETE FROM `" . TABLE_PANEL_TRAFFIC_ADMINS . "` WHERE `adminid`='" . (int)$id . "'");
'page' => $page $db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `adminid` = '" . (int)$userinfo['userid'] . "' WHERE `adminid` = '" . (int)$id . "'");
]); $db->query("UPDATE `" . TABLE_PANEL_DOMAINS . "` SET `adminid` = '" . (int)$userinfo['userid'] . "' WHERE `adminid` = '" . (int)$id . "'");
} else { $log->logAction(ADM_ACTION, LOG_INFO, "deleted admin '" . $result['loginname'] . "'");
HTML::askYesNo('admin_admin_reallydelete', $filename, [ updateCounters();
'id' => $id, redirectTo($filename, Array('page' => $page, 's' => $s));
'page' => $page, }
'action' => $action else
], $result['loginname']); {
ask_yesno('admin_admin_reallydelete', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $result['loginname']);
} }
} }
} elseif ($action == 'add') { }
if (isset($_POST['send']) && $_POST['send'] == 'send') { elseif($action == 'add')
try { {
Admins::getLocal($userinfo, $_POST)->add(); if(isset($_POST['send'])
} catch (Exception $e) { && $_POST['send'] == 'send')
Response::dynamicError($e->getMessage()); {
} $name = validate($_POST['name'], 'name');
Response::redirectTo($filename, [ $email = $idna_convert->encode(validate($_POST['email'], 'email'));
'page' => $page
]); $loginname = validate($_POST['loginname'], 'loginname');
} else { $password = validate($_POST['admin_password'], 'password');
$ipaddress = []; $def_language = validate($_POST['def_language'], 'default language');
$ipaddress[-1] = lng('admin.allips'); $customers = intval_ressource($_POST['customers']);
$ipsandports_stmt = Database::query("
SELECT `id`, `ip` FROM `" . TABLE_PANEL_IPSANDPORTS . "` GROUP BY `ip` ORDER BY `ip` ASC if(isset($_POST['customers_ul']))
"); {
while ($row = $ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) { $customers = - 1;
$ipaddress[$row['id']] = $row['ip'];
} }
$admin_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/admin/formfield.admin_add.php'; $domains = intval_ressource($_POST['domains']);
UI::view('user/form.html.twig', [ if(isset($_POST['domains_ul']))
'formaction' => $linker->getLink(['section' => 'admins']), {
'formdata' => $admin_add_data['admin_add'] $domains = - 1;
]); }
}
} elseif ($action == 'edit' && $id != 0) {
try {
$json_result = Admins::getLocal($userinfo, [
'id' => $id
])->get();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
if ($result['loginname'] != '') { $subdomains = intval_ressource($_POST['subdomains']);
if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { if(isset($_POST['subdomains_ul']))
Admins::getLocal($userinfo, $_POST)->update(); {
} catch (Exception $e) { $subdomains = - 1;
Response::dynamicError($e->getMessage()); }
$emails = intval_ressource($_POST['emails']);
if(isset($_POST['emails_ul']))
{
$emails = - 1;
}
$email_accounts = intval_ressource($_POST['email_accounts']);
if(isset($_POST['email_accounts_ul']))
{
$email_accounts = - 1;
}
$email_forwarders = intval_ressource($_POST['email_forwarders']);
if(isset($_POST['email_forwarders_ul']))
{
$email_forwarders = - 1;
}
if($settings['system']['mail_quota_enabled'] == '1')
{
$email_quota = validate($_POST['email_quota'], 'email_quota', '/^\d+$/', 'vmailquotawrong', array('0', ''));
if(isset($_POST['email_quota_ul']))
{
$email_quota = - 1;
} }
Response::redirectTo($filename, [ }
'page' => $page else
]); {
} else { $email_quota = - 1;
$dec_places = Settings::Get('panel.decimal_places'); }
$result['traffic'] = round($result['traffic'] / (1024 * 1024), $dec_places);
$result['diskspace'] = round($result['diskspace'] / 1024, $dec_places); $ftps = intval_ressource($_POST['ftps']);
if(isset($_POST['ftps_ul']))
{
$ftps = - 1;
}
$tickets = intval_ressource($_POST['tickets']);
if(isset($_POST['tickets_ul'])
&& $settings['ticket']['enabled'] == '1')
{
$tickets = - 1;
}
$mysqls = intval_ressource($_POST['mysqls']);
if(isset($_POST['mysqls_ul']))
{
$mysqls = - 1;
}
if($settings['aps']['aps_active'] == '1')
{
$number_of_aps_packages = intval_ressource($_POST['number_of_aps_packages']);
if(isset($_POST['number_of_aps_packages_ul']))
{
$number_of_aps_packages = - 1;
}
$can_manage_aps_packages = intval($_POST['can_manage_aps_packages']);
}
else
{
$number_of_aps_packages = 0;
$can_manage_aps_packages = 0;
}
$customers_see_all = intval($_POST['customers_see_all']);
$domains_see_all = intval($_POST['domains_see_all']);
$caneditphpsettings = intval($_POST['caneditphpsettings']);
$change_serversettings = intval($_POST['change_serversettings']);
$diskspace = intval_ressource($_POST['diskspace']);
if(isset($_POST['diskspace_ul']))
{
$diskspace = - 1;
}
$traffic = doubleval_ressource($_POST['traffic']);
if(isset($_POST['traffic_ul']))
{
$traffic = - 1;
}
$diskspace = $diskspace * 1024;
$traffic = $traffic * 1024 * 1024;
$ipaddress = intval_ressource($_POST['ipaddress']);
// Check if the account already exists
$loginname_check = $db->query_first("SELECT `loginname` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `loginname` = '" . $db->escape($loginname) . "'");
$loginname_check_admin = $db->query_first("SELECT `loginname` FROM `" . TABLE_PANEL_ADMINS . "` WHERE `loginname` = '" . $db->escape($loginname) . "'");
if($loginname == '')
{
standard_error(array('stringisempty', 'myloginname'));
}
elseif(strtolower($loginname_check['loginname']) == strtolower($loginname)
|| strtolower($loginname_check_admin['loginname']) == strtolower($loginname))
{
standard_error('loginnameexists', $loginname);
}
// Accounts which match systemaccounts are not allowed, filtering them
elseif (preg_match('/^' . preg_quote($settings['customer']['accountprefix'], '/') . '([0-9]+)/', $loginname))
{
standard_error('loginnameissystemaccount', $settings['customer']['accountprefix']);
}
elseif(!validateUsername($loginname))
{
standard_error('loginnameiswrong', $loginname);
}
elseif($name == '')
{
standard_error(array('stringisempty', 'myname'));
}
elseif($email == '')
{
standard_error(array('stringisempty', 'emailadd'));
}
elseif($password == '')
{
standard_error(array('stringisempty', 'mypassword'));
}
elseif(!validateEmail($email))
{
standard_error('emailiswrong', $email);
}
else
{
if($customers_see_all != '1')
{
$customers_see_all = '0';
}
if($domains_see_all != '1')
{
$domains_see_all = '0';
}
if($caneditphpsettings != '1')
{
$caneditphpsettings = '0';
}
if($change_serversettings != '1')
{
$change_serversettings = '0';
}
$result = $db->query("INSERT INTO `" . TABLE_PANEL_ADMINS . "` (`loginname`, `password`, `name`, `email`, `def_language`, `change_serversettings`, `customers`, `customers_see_all`, `domains`, `domains_see_all`, `caneditphpsettings`, `diskspace`, `traffic`, `subdomains`, `emails`, `email_accounts`, `email_forwarders`, `email_quota`, `ftps`, `tickets`, `mysqls`, `ip`, `can_manage_aps_packages`, `aps_packages`)
VALUES ('" . $db->escape($loginname) . "', '" . md5($password) . "', '" . $db->escape($name) . "', '" . $db->escape($email) . "','" . $db->escape($def_language) . "', '" . $db->escape($change_serversettings) . "', '" . $db->escape($customers) . "', '" . $db->escape($customers_see_all) . "', '" . $db->escape($domains) . "', '" . $db->escape($domains_see_all) . "', '" . (int)$caneditphpsettings . "', '" . $db->escape($diskspace) . "', '" . $db->escape($traffic) . "', '" . $db->escape($subdomains) . "', '" . $db->escape($emails) . "', '" . $db->escape($email_accounts) . "', '" . $db->escape($email_forwarders) . "', '" . $db->escape($email_quota) . "', '" . $db->escape($ftps) . "', '" . $db->escape($tickets) . "', '" . $db->escape($mysqls) . "', '" . (int)$ipaddress . "', " . (int)$can_manage_aps_packages . ", " . (int)$number_of_aps_packages . ")");
$adminid = $db->insert_id();
$log->logAction(ADM_ACTION, LOG_INFO, "added admin '" . $loginname . "'");
redirectTo($filename, Array('page' => $page, 's' => $s));
}
}
else
{
$language_options = '';
while(list($language_file, $language_name) = each($languages))
{
$language_options.= makeoption($language_name, $language_file, $userinfo['language'], true);
}
$ipaddress = makeoption($lng['admin']['allips'], "-1");
$ips = array();
$ipsandports = $db->query('SELECT `id`, `ip` FROM `' . TABLE_PANEL_IPSANDPORTS . '` ORDER BY `ip`, `port` ASC');
while($row = $db->fetch_array($ipsandports))
{
if(filter_var($row['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6))
{
$row['ip'] = '[' . $row['ip'] . ']';
}
if(!in_array($row['ip'], $ips))
{
$ipaddress.= makeoption($row['ip'], $row['id']);
$ips[] = $row['ip'];
}
}
$customers_ul = makecheckbox('customers_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$diskspace_ul = makecheckbox('diskspace_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$traffic_ul = makecheckbox('traffic_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$domains_ul = makecheckbox('domains_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$subdomains_ul = makecheckbox('subdomains_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$emails_ul = makecheckbox('emails_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$email_accounts_ul = makecheckbox('email_accounts_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$email_forwarders_ul = makecheckbox('email_forwarders_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$email_quota_ul = makecheckbox('email_quota_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$ftps_ul = makecheckbox('ftps_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$tickets_ul = makecheckbox('tickets_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$mysqls_ul = makecheckbox('mysqls_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$change_serversettings = makeyesno('change_serversettings', '1', '0', '0');
$customers_see_all = makeyesno('customers_see_all', '1', '0', '0');
$domains_see_all = makeyesno('domains_see_all', '1', '0', '0');
$caneditphpsettings = makeyesno('caneditphpsettings', '1', '0', '0');
$can_manage_aps_packages = makeyesno('can_manage_aps_packages', '1', '0', '0');
$number_of_aps_packages_ul = makecheckbox('number_of_aps_packages_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
eval("echo \"" . getTemplate("admins/admins_add") . "\";");
}
}
elseif($action == 'edit'
&& $id != 0)
{
$result = $db->query_first("SELECT * FROM `" . TABLE_PANEL_ADMINS . "` WHERE `adminid`='" . (int)$id . "'");
if($result['loginname'] != '')
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$name = validate($_POST['name'], 'name');
$email = $idna_convert->encode(validate($_POST['email'], 'email'));
if($result['adminid'] == $userinfo['userid'])
{
$password = '';
$def_language = $result['def_language'];
$deactivated = $result['deactivated'];
$customers = $result['customers'];
$domains = $result['domains'];
$subdomains = $result['subdomains'];
$emails = $result['emails'];
$email_accounts = $result['email_accounts'];
$email_forwarders = $result['email_forwarders'];
$email_quota = $result['email_quota'];
$ftps = $result['ftps'];
$tickets = $result['tickets'];
$mysqls = $result['mysqls'];
$customers_see_all = $result['customers_see_all'];
$domains_see_all = $result['domains_see_all'];
$caneditphpsettings = $result['caneditphpsettings'];
$change_serversettings = $result['change_serversettings'];
$diskspace = $result['diskspace'];
$traffic = $result['traffic'];
$ipaddress = $result['ip'];
$can_manage_aps_packages = $result['can_manage_aps_packages'];
$number_of_aps_packages = $result['aps_packages'];
}
else
{
$password = validate($_POST['admin_password'], 'new password');
$def_language = validate($_POST['def_language'], 'default language');
$deactivated = intval($_POST['deactivated']);
$customers = intval_ressource($_POST['customers']);
if(isset($_POST['customers_ul']))
{
$customers = - 1;
}
$domains = intval_ressource($_POST['domains']);
if(isset($_POST['domains_ul']))
{
$domains = - 1;
}
$subdomains = intval_ressource($_POST['subdomains']);
if(isset($_POST['subdomains_ul']))
{
$subdomains = - 1;
}
$emails = intval_ressource($_POST['emails']);
if(isset($_POST['emails_ul']))
{
$emails = - 1;
}
$email_accounts = intval_ressource($_POST['email_accounts']);
if(isset($_POST['email_accounts_ul']))
{
$email_accounts = - 1;
}
$email_forwarders = intval_ressource($_POST['email_forwarders']);
if(isset($_POST['email_forwarders_ul']))
{
$email_forwarders = - 1;
}
if($settings['system']['mail_quota_enabled'] == '1')
{
$email_quota = validate($_POST['email_quota'], 'email_quota', '/^\d+$/', 'vmailquotawrong', array('0', ''));
if(isset($_POST['email_quota_ul']))
{
$email_quota = - 1;
}
}
else
{
$email_quota = - 1;
}
$ftps = intval_ressource($_POST['ftps']);
if(isset($_POST['ftps_ul']))
{
$ftps = - 1;
}
$tickets = intval_ressource($_POST['tickets']);
if(isset($_POST['tickets_ul']))
{
$tickets = - 1;
}
$mysqls = intval_ressource($_POST['mysqls']);
if(isset($_POST['mysqls_ul']))
{
$mysqls = - 1;
}
$number_of_aps_packages = intval_ressource($_POST['number_of_aps_packages']);
if(isset($_POST['number_of_aps_packages_ul']))
{
$number_of_aps_packages = - 1;
}
$customers_see_all = intval($_POST['customers_see_all']);
$domains_see_all = intval($_POST['domains_see_all']);
$caneditphpsettings = intval($_POST['caneditphpsettings']);
$change_serversettings = intval($_POST['change_serversettings']);
$can_manage_aps_packages = intval($_POST['can_manage_aps_packages']);
$diskspace = intval($_POST['diskspace']);
if(isset($_POST['diskspace_ul']))
{
$diskspace = - 1;
}
$traffic = doubleval_ressource($_POST['traffic']);
if(isset($_POST['traffic_ul']))
{
$traffic = - 1;
}
$diskspace = $diskspace * 1024;
$traffic = $traffic * 1024 * 1024;
$ipaddress = intval_ressource($_POST['ipaddress']);
}
if($name == '')
{
standard_error(array('stringisempty', 'myname'));
}
elseif($email == '')
{
standard_error(array('stringisempty', 'emailadd'));
}
elseif(!validateEmail($email))
{
standard_error('emailiswrong', $email);
}
else
{
if($password != '')
{
$password = md5($password);
}
else
{
$password = $result['password'];
}
if($deactivated != '1')
{
$deactivated = '0';
}
if($customers_see_all != '1')
{
$customers_see_all = '0';
}
if($domains_see_all != '1')
{
$domains_see_all = '0';
}
if($caneditphpsettings != '1')
{
$caneditphpsettings = '0';
}
if($change_serversettings != '1')
{
$change_serversettings = '0';
}
$db->query("UPDATE `" . TABLE_PANEL_ADMINS . "` SET `name`='" . $db->escape($name) . "', `email`='" . $db->escape($email) . "', `def_language`='" . $db->escape($def_language) . "', `change_serversettings` = '" . $db->escape($change_serversettings) . "', `customers` = '" . $db->escape($customers) . "', `customers_see_all` = '" . $db->escape($customers_see_all) . "', `domains` = '" . $db->escape($domains) . "', `domains_see_all` = '" . $db->escape($domains_see_all) . "', `caneditphpsettings` = '" . (int)$caneditphpsettings . "', `password` = '" . $password . "', `diskspace`='" . $db->escape($diskspace) . "', `traffic`='" . $db->escape($traffic) . "', `subdomains`='" . $db->escape($subdomains) . "', `emails`='" . $db->escape($emails) . "', `email_accounts` = '" . $db->escape($email_accounts) . "', `email_forwarders`='" . $db->escape($email_forwarders) . "', `email_quota`='" . $db->escape($email_quota) . "', `ftps`='" . $db->escape($ftps) . "', `tickets`='" . $db->escape($tickets) . "', `mysqls`='" . $db->escape($mysqls) . "', `ip`='" . (int)$ipaddress . "', `deactivated`='" . $db->escape($deactivated) . "', `can_manage_aps_packages`=" . (int)$can_manage_aps_packages . ", `aps_packages`=" . (int)$number_of_aps_packages . " WHERE `adminid`='" . $db->escape($id) . "'");
$log->logAction(ADM_ACTION, LOG_INFO, "edited admin '#" . $id . "'");
$redirect_props = Array(
'page' => $page,
's' => $s
);
redirectTo($filename, $redirect_props);
}
}
else
{
$result['traffic'] = round($result['traffic'] / (1024 * 1024), $settings['panel']['decimal_places']);
$result['diskspace'] = round($result['diskspace'] / 1024, $settings['panel']['decimal_places']);
$result['email'] = $idna_convert->decode($result['email']); $result['email'] = $idna_convert->decode($result['email']);
$customers_ul = makecheckbox('customers_ul', $lng['customer']['unlimited'], '-1', false, $result['customers'], true, true);
$ipaddress = []; if($result['customers'] == '-1')
$ipaddress[-1] = lng('admin.allips'); {
$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 = makecheckbox('diskspace_ul', $lng['customer']['unlimited'], '-1', false, $result['diskspace'], true, true);
$admin_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/admin/formfield.admin_edit.php'; if($result['diskspace'] == '-1')
{
$result['diskspace'] = '';
}
UI::view('user/form.html.twig', [ $traffic_ul = makecheckbox('traffic_ul', $lng['customer']['unlimited'], '-1', false, $result['traffic'], true, true);
'formaction' => $linker->getLink(['section' => 'admins', 'id' => $id]),
'formdata' => $admin_edit_data['admin_edit'], if($result['traffic'] == '-1')
'editid' => $id {
]); $result['traffic'] = '';
}
$domains_ul = makecheckbox('domains_ul', $lng['customer']['unlimited'], '-1', false, $result['domains'], true, true);
if($result['domains'] == '-1')
{
$result['domains'] = '';
}
$subdomains_ul = makecheckbox('subdomains_ul', $lng['customer']['unlimited'], '-1', false, $result['subdomains'], true, true);
if($result['subdomains'] == '-1')
{
$result['subdomains'] = '';
}
$emails_ul = makecheckbox('emails_ul', $lng['customer']['unlimited'], '-1', false, $result['emails'], true, true);
if($result['emails'] == '-1')
{
$result['emails'] = '';
}
$email_accounts_ul = 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 = 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 = makecheckbox('email_quota_ul', $lng['customer']['unlimited'], '-1', false, $result['email_quota'], true, true);
if($result['email_quota'] == '-1')
{
$result['email_quota'] = '';
}
$ftps_ul = makecheckbox('ftps_ul', $lng['customer']['unlimited'], '-1', false, $result['ftps'], true, true);
if($result['ftps'] == '-1')
{
$result['ftps'] = '';
}
$tickets_ul = makecheckbox('tickets_ul', $lng['customer']['unlimited'], '-1', false, $result['tickets'], true, true);
if($result['tickets'] == '-1')
{
$result['tickets'] = '';
}
$mysqls_ul = makecheckbox('mysqls_ul', $lng['customer']['unlimited'], '-1', false, $result['mysqls'], true, true);
if($result['mysqls'] == '-1')
{
$result['mysqls'] = '';
}
$number_of_aps_packages_ul = makecheckbox('number_of_aps_packages_ul', $lng['customer']['unlimited'], '-1', false, $result['aps_packages'], true, true);
if($result['aps_packages'] == '-1')
{
$result['aps_packages'] = '';
}
$language_options = '';
while(list($language_file, $language_name) = each($languages))
{
$language_options.= makeoption($language_name, $language_file, $result['def_language'], true);
}
$ipaddress = makeoption($lng['admin']['allips'], "-1", $result['ip']);
$ips = array();
$ipsandports = $db->query('SELECT `id`, `ip` FROM `' . TABLE_PANEL_IPSANDPORTS . '` ORDER BY `ip`, `port` ASC');
while($row = $db->fetch_array($ipsandports))
{
if(filter_var($row['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6))
{
$row['ip'] = '[' . $row['ip'] . ']';
}
if(!in_array($row['ip'], $ips))
{
$ipaddress.= makeoption($row['ip'], $row['id'], $result['ip']);
$ips[] = $row['ip'];
}
}
$change_serversettings = makeyesno('change_serversettings', '1', '0', $result['change_serversettings']);
$customers_see_all = makeyesno('customers_see_all', '1', '0', $result['customers_see_all']);
$domains_see_all = makeyesno('domains_see_all', '1', '0', $result['domains_see_all']);
$caneditphpsettings = makeyesno('caneditphpsettings', '1', '0', $result['caneditphpsettings']);
$deactivated = makeyesno('deactivated', '1', '0', $result['deactivated']);
$can_manage_aps_packages = makeyesno('can_manage_aps_packages', '1', '0', $result['can_manage_aps_packages']);
$result = htmlentities_array($result);
eval("echo \"" . getTemplate("admins/admins_edit") . "\";");
} }
} }
} }
} }
?>

View File

@@ -1,234 +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>
* @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
*/
use Froxlor\FroxlorLogger;
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
if ($action == 'delete' && function_exists('apcu_clear_cache') && $userinfo['change_serversettings'] == '1') {
if ($_POST['send'] == 'send') {
apcu_clear_cache();
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "cleared APCu cache");
header('Location: ' . $linker->getLink([
'section' => 'apcuinfo',
'page' => 'showinfo'
]));
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')) {
Response::standardError(lng('error.no_apcuinfo'));
}
if ($page == 'showinfo' && $userinfo['change_serversettings'] == '1') {
$cache = apcu_cache_info();
$mem = apcu_sma_info();
$time = time();
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_apcuinfo");
// check for possible empty values that are used in the templates
if (!isset($cache['file_upload_progress'])) {
$cache['file_upload_progress'] = lng('logger.unknown');
}
if (!isset($cache['num_expunges'])) {
$cache['num_expunges'] = lng('logger.unknown');
}
$overview = [
'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) {
$value = $v['local_value'];
$overview['runtimelines'][$name] = $value;
}
// Fragementation: (freeseg - 1) / total_seg
$nseg = $freeseg = $fragsize = $freetotal = 0;
for ($i = 0; $i < $mem['num_seg']; $i++) {
$ptr = 0;
foreach ($mem['block_lists'][$i] as $block) {
if ($block['offset'] != $ptr) {
++$nseg;
}
$ptr = $block['offset'] + $block['size'];
/* Only consider blocks <5M for the fragmentation % */
if ($block['size'] < (5 * 1024 * 1024)) {
$fragsize += $block['size'];
}
$freetotal += $block['size'];
}
$freeseg += count($mem['block_lists'][$i]);
}
$overview['fragmentation'] = [];
if ($freeseg > 1) {
$overview['fragmentation']['used_percentage'] = number_format(($fragsize / $freetotal) * 100, 1);
$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 {
$overview['fragmentation'] = 0;
}
UI::view('settings/apcuinfo.html.twig', [
'apcuinfo' => $overview
]);
}
// 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',
$size,
'',
$val[$i]
);
}
function duration($ts)
{
global $time;
$years = (int)((($time - $ts) / (7 * 86400)) / 52.177457);
$rem = (int)(($time - $ts) - ($years * 52.177457 * 7 * 86400));
$weeks = (int)(($rem) / (7 * 86400));
$days = (int)(($rem) / 86400) - $weeks * 7;
$hours = (int)(($rem) / 3600) - $days * 24 - $weeks * 7 * 24;
$mins = (int)(($rem) / 60) - $hours * 60 - $days * 24 * 60 - $weeks * 7 * 24 * 60;
$str = '';
if ($years == 1) {
$str .= "$years year, ";
}
if ($years > 1) {
$str .= "$years years, ";
}
if ($weeks == 1) {
$str .= "$weeks week, ";
}
if ($weeks > 1) {
$str .= "$weeks weeks, ";
}
if ($days == 1) {
$str .= "$days day,";
}
if ($days > 1) {
$str .= "$days days,";
}
if ($hours == 1) {
$str .= " $hours hour and";
}
if ($hours > 1) {
$str .= " $hours hours and";
}
if ($mins == 1) {
$str .= " 1 minute";
} else {
$str .= " $mins minutes";
}
return $str;
}

35
admin_aps.php Normal file
View File

@@ -0,0 +1,35 @@
<?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 Panel
* @version $Id$
*/
// Required code
define('AREA', 'admin');
require ("./lib/init.php");
require ("./lib/class_apsparser.php");
$Id = 0;
if(isset($_GET['id']))$Id = (int)$_GET['id'];
if(isset($_POST['id']))$Id = (int)$_POST['id'];
eval("echo \"" . getTemplate("aps/header") . "\";");
$Aps = new ApsParser($userinfo, $settings, $db);
$Aps->MainHandler($action);
eval("echo \"" . getTemplate("aps/footer") . "\";");
?>

View File

@@ -1,212 +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\Froxlor;
use Froxlor\FroxlorLogger;
use Froxlor\Http\HttpClient;
use Froxlor\Install\AutoUpdate;
use Froxlor\Settings;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Response;
if ($page != 'error') {
// check for webupdate to be enabled
if (Settings::Config('enable_webupdate') != true) {
Response::redirectTo($filename, [
'page' => 'error',
'errno' => 11
]);
}
}
// display initial version check
if ($page == 'overview') {
// log our actions
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "checking auto-update");
// check for new version
try {
$result = AutoUpdate::checkVersion();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
if ($result == 1) {
// anzeige über version-status mit ggfls. formular
// zum update schritt #1 -> download
$text = lng('admin.newerversionavailable') . ' ' . lng('admin.newerversiondetails', [AutoUpdate::getFromResult('version'), Froxlor::VERSION]);
$upd_formfield = [
'updates' => [
'title' => lng('update.update'),
'image' => 'fa-solid fa-download',
'sections' => [
'section_autoupd' => [
'fields' => [
'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 {
Response::redirectTo($filename, [
'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
elseif ($page == 'getdownload') {
// retrieve the new version from the form
$newversion = isset($_POST['newversion']) ? $_POST['newversion'] : null;
$result = 6;
// valid?
if ($newversion !== null) {
$result = AutoUpdate::downloadZip($newversion);
if (!is_numeric($result)) {
// to the next step
Response::redirectTo($filename, [
'page' => 'extract',
'archive' => $result
]);
}
}
Response::redirectTo($filename, [
'page' => 'error',
'errno' => $result
]);
} // extract and install new version
elseif ($page == 'extract') {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
$toExtract = isset($_POST['archive']) ? $_POST['archive'] : null;
$localArchive = Froxlor::getInstallDir() . '/updates/' . $toExtract;
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "Extracting " . $localArchive . " to " . Froxlor::getInstallDir());
$result = AutoUpdate::extractZip($localArchive);
if ($result > 0) {
// error
Response::redirectTo($filename, [
'page' => 'error',
'errno' => $result
]);
}
// redirect to update-page
Response::redirectTo('admin_updates.php');
} else {
$toExtract = isset($_GET['archive']) ? $_GET['archive'] : null;
$localArchive = Froxlor::getInstallDir() . '/updates/' . $toExtract;
}
if (!file_exists($localArchive)) {
Response::redirectTo($filename, [
'page' => 'error',
'errno' => 7
]);
}
$text = lng('admin.extractdownloadedzip', [$toExtract]);
$upd_formfield = [
'updates' => [
'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
elseif ($page == 'error') {
// retrieve error-number via url-parameter
$errno = isset($_GET['errno']) ? (int)$_GET['errno'] : 0;
// 2 = no Zlib
// 3 = custom version detected
// 4 = could not store archive to local hdd
// 5 = some weird value came from version.froxlor.org
// 6 = download without valid version
// 7 = local archive does not exist
// 8 = could not extract archive
// 9 = checksum mismatch
// 10 = <php-7.4
// 11 = enable_webupdate = false
$errmsg = 'autoupdate_' . $errno;
if ($errno == 3) {
$errmsg = 'customized_version';
}
Response::standardError($errmsg);
}

View File

@@ -2,180 +2,180 @@
/** /**
* 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 * @version $Id$
* 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'; define('AREA', 'admin');
require __DIR__ . '/lib/init.php';
use Froxlor\Config\ConfigParser; /**
use Froxlor\FileDir; * Include our init.php, which manages Sessions, Language etc.
use Froxlor\Froxlor; */
use Froxlor\Settings;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
use Froxlor\UI\Response;
if ($userinfo['change_serversettings'] == '1') { $need_db_sql_data = true;
if ($action == 'setconfigured') { require ("./lib/init.php");
Settings::Set('panel.is_configured', '1', true); require ("./lib/configfiles_index.inc.php");
Response::redirectTo('admin_configfiles.php'); $distribution = '';
} $distributions_select = '';
$service = '';
$services_select = '';
$daemon = '';
$daemons_select = '';
// get distro from URL param if($userinfo['change_serversettings'] == '1')
$distribution = Request::any('distribution'); {
$reselect = Request::any('reselect', 0); if(isset($_GET['distribution'])
&& $_GET['distribution'] != ''
&& isset($configfiles[$_GET['distribution']])
&& is_array($configfiles[$_GET['distribution']]))
{
$distribution = $_GET['distribution'];
// check for possible setting if(isset($_GET['service'])
if (empty($distribution)) { && $_GET['service'] != ''
$distribution = Settings::Get('system.distribution') ?? ""; && isset($configfiles[$distribution]['services'][$_GET['service']])
} && is_array($configfiles[$distribution]['services'][$_GET['service']]))
if ($reselect == 1) { {
$distribution = ''; $service = $_GET['service'];
}
$distributions_select = []; if(isset($_GET['daemon'])
&& $_GET['daemon'] != ''
$services = []; && isset($configfiles[$distribution]['services'][$service]['daemons'][$_GET['daemon']])
$config_dir = FileDir::makeCorrectDir(Froxlor::getInstallDir() . '/lib/configfiles/'); && is_array($configfiles[$distribution]['services'][$service]['daemons'][$_GET['daemon']]))
{
if (!empty($distribution)) { $daemon = $_GET['daemon'];
if (!file_exists($config_dir . '/' . $distribution . ".xml")) { }
Response::dynamicError("Unknown distribution"); else
{
foreach($configfiles[$distribution]['services'][$service]['daemons'] as $daemon_name => $daemon_details)
{
$daemons_select.= makeoption($daemon_details['label'], $daemon_name);
}
}
} }
else
// update setting if different {
if ($distribution != Settings::Get('system.distribution')) { foreach($configfiles[$distribution]['services'] as $service_name => $service_details)
Settings::Set('system.distribution', $distribution); {
$services_select.= makeoption($service_details['label'], $service_name);
}
} }
// create configparser object
$configfiles = new ConfigParser($config_dir . '/' . $distribution . ".xml");
// get distro-info
$dist_display = $configfiles->getCompleteDistroName();
// get all the services from the distro
$services = $configfiles->getServices();
} else {
// show list of available distro's
$distros = glob($config_dir . '*.xml');
// read in all the distros
foreach ($distros as $_distribution) {
// get configparser object
$dist = new ConfigParser($_distribution);
// store in tmp array
$distributions_select[str_replace(".xml", "", strtolower(basename($_distribution)))] = $dist->getCompleteDistroName();
}
// sort by distribution name
asort($distributions_select);
} }
else
if ($distribution != "" && isset($_POST['finish'])) { {
unset($_POST['finish']); foreach($configfiles as $distribution_name => $distribution_details)
$params = $_POST; {
$params['distro'] = $distribution; $distributions_select.= makeoption($distribution_details['label'], $distribution_name);
$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', [
'distribution' => $distribution,
// alert
'type' => 'info',
'alert_msg' => lng('admin.configfiles.finishnote'),
'basedir' => Froxlor::getInstallDir(),
'params_filename' => $params_filename
]);
} else {
if (!empty($distribution)) {
// show available services to configure
$fields = $services;
$link_params = ['section' => 'configfiles', 'distribution' => $distribution];
UI::twigBuffer('settings/configuration.html.twig', [
'action' => $linker->getLink($link_params),
'fields' => $fields,
'distribution' => $distribution
]);
} else {
// @fixme check set distribution from settings
$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(); if($distribution != ''
} else { && $service != ''
Response::redirectTo('admin_index.php'); && $daemon != '')
{
$replace_arr = Array(
'<SQL_UNPRIVILEGED_USER>' => $sql['user'],
'<SQL_UNPRIVILEGED_PASSWORD>' => 'MYSQL_PASSWORD',
'<SQL_DB>' => $sql['db'],
'<SQL_HOST>' => $sql['host'],
'<SERVERNAME>' => $settings['system']['hostname'],
'<SERVERIP>' => $settings['system']['ipaddress'],
'<NAMESERVERS>' => $settings['system']['nameservers'],
'<VIRTUAL_MAILBOX_BASE>' => $settings['system']['vmail_homedir'],
'<VIRTUAL_UID_MAPS>' => $settings['system']['vmail_uid'],
'<VIRTUAL_GID_MAPS>' => $settings['system']['vmail_gid'],
'<AWSTATS_PATH>' => $settings['system']['awstats_path'],
'<SSLPROTOCOLS>' => ($settings['system']['use_ssl'] == '1') ? 'imaps pop3s' : '',
'<REALTIME_PORT>' => $settings['system']['realtime_port']
);
$files = '';
$configpage = '';
foreach($configfiles[$distribution]['services'][$service]['daemons'][$daemon] as $action => $value)
{
if(substr($action, 0, 8) == 'commands')
{
$commands = '';
if(is_array($value))
{
$commands = implode("\n", $value);
if($commands != '')
{
eval("\$configpage.=\"" . getTemplate("configfiles/configfiles_commands") . "\";");
}
}
}
elseif(substr($action, 0, 5) == 'files')
{
$files = '';
if(is_array($value))
{
while(list($filename, $realname) = each($value))
{
$file_content = file_get_contents('./templates/misc/configfiles/' . $distribution . '/' . $daemon . '/' . $filename);
$file_content = strtr($file_content, $replace_arr);
$file_content = htmlspecialchars($file_content);
$numbrows = count(explode("\n", $file_content));
eval("\$files.=\"" . getTemplate("configfiles/configfiles_file") . "\";");
}
eval("\$configpage.=\"" . getTemplate("configfiles/configfiles_files") . "\";");
}
}
}
if(isset($configfiles[$distribution]['services'][$service]['daemons'][$daemon]['restart'])
&& is_array($configfiles[$distribution]['services'][$service]['daemons'][$daemon]['restart']))
{
$restart = implode("\n", $configfiles[$distribution]['services'][$service]['daemons'][$daemon]['restart']);
}
else
{
$restart = '';
}
eval("echo \"" . getTemplate("configfiles/configfiles") . "\";");
}
elseif($page == 'overview')
{
$log->logAction(ADM_ACTION, LOG_NOTICE, "viewed admin_configfiles");
$distributions = '';
foreach($configfiles as $distribution_name => $distribution_details)
{
$services = '';
foreach($distribution_details['services'] as $service_name => $service_details)
{
$daemons = '';
foreach($service_details['daemons'] as $daemon_name => $daemon_details)
{
eval("\$daemons.=\"" . getTemplate("configfiles/choose_daemon") . "\";");
}
eval("\$services.=\"" . getTemplate("configfiles/choose_service") . "\";");
}
eval("\$distributions.=\"" . getTemplate("configfiles/choose_distribution") . "\";");
}
eval("echo \"" . getTemplate("configfiles/choose") . "\";");
}
else
{
eval("echo \"" . getTemplate("configfiles/wizard") . "\";");
}
} }
?>

View File

@@ -4,92 +4,113 @@
* 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
* * @version $Id$
* 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'; define('AREA', 'admin');
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\Cronjobs; require_once("./lib/init.php");
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'
if ($action == '') { || $page == 'overview')
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'viewed admin_cronjobs'); {
if($action == '')
{
$log->logAction(ADM_ACTION, LOG_NOTICE, "viewed admin_cronjobs");
try { $fields = array(
$cron_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.cronjobs.php'; 'c.lastrun' => $lng['cron']['lastrun'],
$collection = (new Collection(Cronjobs::class, $userinfo)) 'c.interval' => $lng['cron']['interval'],
->withPagination($cron_list_data['cron_list']['columns'], $cron_list_data['cron_list']['default_sorting']); 'c.isactive' => $lng['cron']['isactive']
} catch (Exception $e) { );
Response::dynamicError($e->getMessage()); $paging = new paging($userinfo, $db, TABLE_PANEL_CRONRUNS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
}
UI::view('user/table-note.html.twig', [
'listing' => Listing::format($collection, $cron_list_data, 'cron_list'),
// alert-box
'type' => 'warning',
'alert_msg' => lng('cron.changewarning')
]);
} elseif ($action == 'new') {
/* /*
* @TODO later * @TODO Fix sorting
*/ */
} elseif ($action == 'edit' && $id != 0) { $crons = '';
try { $result = $db->query("SELECT `c`.* FROM `" . TABLE_PANEL_CRONRUNS . "` `c` ORDER BY `cronfile` ASC");
$json_result = Cronjobs::getLocal($userinfo, [ $paging->setEntries($db->num_rows($result));
'id' => $id $sortcode = $paging->getHtmlSortCode($lng);
])->get(); $arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
} catch (Exception $e) { $searchcode = $paging->getHtmlSearchCode($lng);
Response::dynamicError($e->getMessage()); $pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
}
$result = json_decode($json_result, true)['data'];
if ($result['cronfile'] != '') {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
try {
Cronjobs::getLocal($userinfo, $_POST)->update();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
Response::redirectTo($filename, [
'page' => $page
]);
} else {
$cronjobs_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/cronjobs/formfield.cronjobs_edit.php';
UI::view('user/form.html.twig', [ $i = 0;
'formaction' => $linker->getLink(['section' => 'cronjobs', 'id' => $id]), $count = 0;
'formdata' => $cronjobs_edit_data['cronjobs_edit'],
'editid' => $id while($row = $db->fetch_array($result))
]); {
if($paging->checkDisplay($i))
{
$row = htmlentities_array($row);
$row['lastrun'] = date('d.m.Y H:i', $row['lastrun']);
if((int)$row['isactive'] == 1)
{
$row['isactive'] = $lng['panel']['yes'];
}
else
{
$row['isactive'] = $lng['panel']['no'];
}
$description = $lng['crondesc'][$row['desc_lng_key']];
/*
* don't allow deletion of 'froxlor' cronjobs
*/
$vendor_a = explode('/', $row['module']);
$vendor = $vendor_a[0];
eval("\$crons.=\"" . getTemplate("cronjobs/cronjobs_cronjob") . "\";");
$count++;
} }
$i++;
} }
} elseif ($action == 'delete' && $id != 0) {
eval("echo \"" . getTemplate("cronjobs/cronjobs") . "\";");
}
elseif($action == 'new')
{
/* /*
* @TODO later * @TODO Finish me
*/
}
elseif($action == 'edit'
&& $id != 0)
{
/*
* @TODO Finish me
*/
}
elseif($action == 'delete'
&& $id != 0)
{
/*
* @TODO Finish me
*/ */
} }
} }
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -2,169 +2,186 @@
/** /**
* 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 * @version $Id$
* 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'; define('AREA', 'admin');
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\Admins as Admins; /**
use Froxlor\Api\Commands\Froxlor as Froxlor; * Include our init.php, which manages Sessions, Language etc.
use Froxlor\CurrentUser; */
use Froxlor\Database\Database;
use Froxlor\FroxlorLogger;
use Froxlor\Settings;
use Froxlor\System\Cronjob;
use Froxlor\System\Crypt;
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'); require ("./lib/init.php");
if ($action == 'logout') { if($action == 'logout')
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "logged out"); {
unset($_SESSION['userinfo']); $log->logAction(ADM_ACTION, LOG_NOTICE, "logged out");
CurrentUser::setData();
session_destroy();
Response::redirectTo('index.php'); if($settings['session']['allow_multiple_login'] == '1')
} elseif ($action == 'suback') { {
if (is_array(CurrentUser::getField('switched_user'))) { $db->query("DELETE FROM `" . TABLE_PANEL_SESSIONS . "` WHERE `userid` = '" . (int)$userinfo['adminid'] . "' AND `adminsession` = '1' AND `hash` = '" . $s . "'");
$result = CurrentUser::getData();
$result = $result['switched_user'];
CurrentUser::setData($result);
$target = (isset($_GET['target']) ? $_GET['target'] : 'index');
$redirect = "admin_" . $target . ".php";
if (!file_exists(\Froxlor\Froxlor::getInstallDir() . "/" . $redirect)) {
$redirect = "admin_index.php";
}
Response::redirectTo($redirect, null, true);
} else {
Response::dynamicError("Cannot change back - You've never switched to another user :-)");
} }
else
{
$db->query("DELETE FROM `" . TABLE_PANEL_SESSIONS . "` WHERE `userid` = '" . (int)$userinfo['adminid'] . "' AND `adminsession` = '1'");
}
redirectTo('index.php');
exit;
} }
if ($page == 'overview') { if(isset($_POST['id']))
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_index"); {
$params = []; $id = intval($_POST['id']);
if ($userinfo['customers_see_all'] == '0') { }
$params = [ elseif(isset($_GET['id']))
'adminid' => $userinfo['adminid'] {
]; $id = intval($_GET['id']);
} }
$overview_stmt = Database::prepare("SELECT COUNT(*) AS `number_customers`,
SUM(case when `diskspace` > 0 then `diskspace` else 0 end) AS `diskspace_assigned`, if($page == 'overview')
{
$log->logAction(ADM_ACTION, LOG_NOTICE, "viewed admin_index");
$overview = $db->query_first("SELECT COUNT(*) AS `number_customers`,
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(`tickets_used`) AS `tickets_used`,
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` SUM(`aps_packages_used`) AS `aps_packages_used`
FROM `" . TABLE_PANEL_CUSTOMERS . "`" . ($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = :adminid ")); FROM `" . TABLE_PANEL_CUSTOMERS . "`" . ($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = '" . (int)$userinfo['adminid'] . "' "));
$overview = Database::pexecute_first($overview_stmt, $params); $overview['traffic_used'] = round($overview['traffic_used'] / (1024 * 1024), $settings['panel']['decimal_places']);
$overview['diskspace_used'] = round($overview['diskspace_used'] / 1024, $settings['panel']['decimal_places']);
$userinfo['diskspace_bytes'] = ($userinfo['diskspace'] > -1) ? $userinfo['diskspace'] * 1024 : -1; $number_domains = $db->query_first("SELECT COUNT(*) AS `number_domains` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `parentdomainid`='0'" . ($userinfo['customers_see_all'] ? '' : " AND `adminid` = '" . (int)$userinfo['adminid'] . "' "));
$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;
$number_domains_stmt = Database::prepare("
SELECT COUNT(*) AS `number_domains` FROM `" . TABLE_PANEL_DOMAINS . "`
WHERE `parentdomainid`='0'" . ($userinfo['customers_see_all'] ? '' : " AND `adminid` = :adminid"));
$number_domains = Database::pexecute_first($number_domains_stmt, $params);
$overview['number_domains'] = $number_domains['number_domains']; $overview['number_domains'] = $number_domains['number_domains'];
$phpversion = phpversion();
$phpmemorylimit = @ini_get("memory_limit");
if ((isset($_GET['lookfornewversion']) && $_GET['lookfornewversion'] == 'yes') || (isset($lookfornewversion) && $lookfornewversion == 'yes')) { if($phpmemorylimit == "")
try { {
$json_result = Froxlor::getLocal($userinfo)->checkUpdate(); $phpmemorylimit = $lng['admin']['memorylimitdisabled'];
} catch (Exception $e) { }
Response::dynamicError($e->getMessage());
$mysqlserverversion = mysql_get_server_info();
$mysqlclientversion = mysql_get_client_info();
$webserverinterface = strtoupper(@php_sapi_name());
if((isset($_GET['lookfornewversion']) && $_GET['lookfornewversion'] == 'yes')
|| (isset($lookfornewversion) && $lookfornewversion == 'yes'))
{
$update_check_uri = 'http://version.froxlor.org/Froxlor/legacy/' . $version;
if(strtolower(ini_get('allow_url_fopen')) == 'on')
{
$latestversion = @file($update_check_uri);
$latestversion = explode(':', $latestversion);
if(is_array($latestversion)
&& count($latestversion) >= 2)
{
$lookfornewversion_lable = $latestversion[0];
$lookfornewversion_link = $latestversion[1];
$lookfornewversion_addinfo = '';
if(count($latestversion) >= 3)
{
$lookfornewversion_addinfo = $latestversion[2];
}
}
else
{
redirectTo($update_check_uri.'/pretty', NULL);
}
} }
$result = json_decode($json_result, true)['data']; else
{
$lookfornewversion_lable = $result['version']; redirectTo($update_check_uri.'/pretty', NULL);
$lookfornewversion_link = $result['link']; }
$lookfornewversion_message = $result['message']; }
$lookfornewversion_addinfo = $result['additional_info']; else
$isnewerversion = $result['isnewerversion']; {
} else { $lookfornewversion_lable = $lng['admin']['lookfornewversion']['clickhere'];
$lookfornewversion_lable = lng('admin.lookfornewversion.clickhere'); $lookfornewversion_link = htmlspecialchars($filename . '?s=' . urlencode($s) . '&page=' . urlencode($page) . '&lookfornewversion=yes');
$lookfornewversion_link = htmlspecialchars($filename . '?page=' . urlencode($page) . '&lookfornewversion=yes');
$lookfornewversion_message = '';
$lookfornewversion_addinfo = ''; $lookfornewversion_addinfo = '';
$isnewerversion = 0;
} }
$cron_last_runs = Cronjob::getCronjobsLastRun(); $userinfo['diskspace'] = round($userinfo['diskspace'] / 1024, $settings['panel']['decimal_places']);
$outstanding_tasks = Cronjob::getOutstandingTasks(); $userinfo['diskspace_used'] = round($userinfo['diskspace_used'] / 1024, $settings['panel']['decimal_places']);
$userinfo['traffic'] = round($userinfo['traffic'] / (1024 * 1024), $settings['panel']['decimal_places']);
$userinfo['traffic_used'] = round($userinfo['traffic_used'] / (1024 * 1024), $settings['panel']['decimal_places']);
$userinfo = str_replace_array('-1', $lng['customer']['unlimited'], $userinfo, 'customers domains diskspace traffic mysqls emails email_accounts email_forwarders email_quota ftps tickets subdomains aps_packages');
// additional sys-infos $cron_last_runs = getCronjobsLastRun();
$meminfo = explode("\n", @file_get_contents("/proc/meminfo")); $outstanding_tasks = getOutstandingTasks();
$memory = "";
for ($i = 0; $i < count($meminfo); ++$i) { $opentickets = 0;
if (substr($meminfo[$i], 0, 3) === "Mem") { $opentickets = $db->query_first('SELECT COUNT(`id`) as `count` FROM `' . TABLE_PANEL_TICKETS . '`
$memory .= $meminfo[$i] . PHP_EOL; WHERE `answerto` = "0" AND (`status` = "0" OR `status` = "1")
} AND `lastreplier`="0" AND `adminid` = "' . $userinfo['adminid'] . '"');
$awaitingtickets = $opentickets['count'];
$awaitingtickets_text = '';
if($opentickets > 0)
{
$awaitingtickets_text = strtr($lng['ticket']['awaitingticketreply'], array('%s' => '<a href="admin_tickets.php?page=tickets&amp;s=' . $s . '">' . $opentickets['count'] . '</a>'));
} }
if (function_exists('sys_getloadavg')) { if(function_exists('sys_getloadavg'))
{
$loadArray = sys_getloadavg(); $loadArray = sys_getloadavg();
$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 SysCP - 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);
$minutes = $seconds / 60; $minutes = $seconds / 60;
$hours = $minutes / 60; $hours = $minutes / 60;
@@ -173,136 +190,91 @@ 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 :/
$sysinfo = [ $uptime = '';
'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') {
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')) {
Response::standardError('oldpasswordnotcorrect');
}
try {
$new_password = Crypt::validatePassword($_POST['new_password'], 'new password');
$new_password_confirm = Crypt::validatePassword($_POST['new_password_confirm'], 'new password confirm');
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
if ($old_password == '') {
Response::standardError([
'stringisempty',
'changepassword.old_password'
]);
} elseif ($new_password == '') {
Response::standardError([
'stringisempty',
'changepassword.new_password'
]);
} elseif ($new_password_confirm == '') {
Response::standardError([
'stringisempty',
'changepassword.new_password_confirm'
]);
} elseif ($new_password != $new_password_confirm) {
Response::standardError('newpasswordconfirmerror');
} else {
try {
Admins::getLocal($userinfo, [
'id' => $userinfo['adminid'],
'admin_password' => $new_password
])->update();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'changed password');
Response::redirectTo($filename);
}
} else {
UI::view('user/change_password.html.twig');
} }
} elseif ($page == 'change_language') {
$languages = Language::getLanguages();
if (isset($_POST['send']) && $_POST['send'] == 'send') {
$def_language = Validate::validate($_POST['def_language'], 'default language');
if (isset($languages[$def_language])) { eval("echo \"" . getTemplate("index/index") . "\";");
try {
Admins::getLocal($userinfo, [
'id' => $userinfo['adminid'],
'def_language' => $def_language
])->update();
CurrentUser::setField('language', $def_language);
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
}
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "changed his/her default language to '" . $def_language . "'");
Response::redirectTo($filename);
} else {
$default_lang = Settings::Get('panel.standardlanguage');
if ($userinfo['def_language'] != '') {
$default_lang = $userinfo['def_language'];
}
UI::view('user/change_language.html.twig', [
'languages' => $languages,
'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 . "'");
Response::redirectTo($filename);
} else {
$default_theme = Settings::Get('panel.default_theme');
if ($userinfo['theme'] != '') {
$default_theme = $userinfo['theme'];
}
$themes_avail = UI::getThemes();
UI::view('user/change_theme.html.twig', [
'themes' => $themes_avail,
'default_theme' => $default_theme
]);
}
} elseif ($page == 'send_error_report' && Settings::Get('system.allow_error_report_admin') == '1') {
require_once __DIR__ . '/error_report.php';
} elseif ($page == 'apikeys' && Settings::Get('api.enabled') == 1) {
require_once __DIR__ . '/api_keys.php';
} elseif ($page == '2fa' && Settings::Get('2fa.enabled') == 1) {
require_once __DIR__ . '/2fa.php';
} }
elseif($page == 'change_password')
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$old_password = validate($_POST['old_password'], 'old password');
if(md5($old_password) != $userinfo['password'])
{
standard_error('oldpasswordnotcorrect');
exit;
}
$new_password = validate($_POST['new_password'], 'new password');
$new_password_confirm = validate($_POST['new_password_confirm'], 'new password confirm');
if($old_password == '')
{
standard_error(array('stringisempty', 'oldpassword'));
}
elseif($new_password == '')
{
standard_error(array('stringisempty', 'newpassword'));
}
elseif($new_password_confirm == '')
{
standard_error(array('stringisempty', 'newpasswordconfirm'));
}
elseif($new_password != $new_password_confirm)
{
standard_error('newpasswordconfirmerror');
}
else
{
$db->query("UPDATE `" . TABLE_PANEL_ADMINS . "` SET `password`='" . md5($new_password) . "' WHERE `adminid`='" . (int)$userinfo['adminid'] . "' AND `password`='" . md5($old_password) . "'");
$log->logAction(ADM_ACTION, LOG_NOTICE, 'changed password');
redirectTo($filename, Array('s' => $s));
}
}
else
{
eval("echo \"" . getTemplate("index/change_password") . "\";");
}
}
elseif($page == 'change_language')
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$def_language = validate($_POST['def_language'], 'default language');
if(isset($languages[$def_language]))
{
$db->query("UPDATE `" . TABLE_PANEL_ADMINS . "` SET `def_language`='" . $db->escape($def_language) . "' WHERE `adminid`='" . (int)$userinfo['adminid'] . "'");
$db->query("UPDATE `" . TABLE_PANEL_SESSIONS . "` SET `language`='" . $db->escape($def_language) . "' WHERE `hash`='" . $db->escape($s) . "'");
}
$log->logAction(ADM_ACTION, LOG_NOTICE, "changed his/her default language to '" . $def_language . "'");
redirectTo($filename, Array('s' => $s));
}
else
{
$language_options = '';
while(list($language_file, $language_name) = each($languages))
{
$language_options.= makeoption($language_name, $language_file, $userinfo['def_language'], true);
}
eval("echo \"" . getTemplate("index/change_language") . "\";");
}
}
?>

View File

@@ -2,152 +2,319 @@
/** /**
* 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 * @version $Id$
* 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'; define('AREA', 'admin');
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\IpsAndPorts; /**
use Froxlor\FroxlorLogger; * Include our init.php, which manages Sessions, Language etc.
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'); require ("./lib/init.php");
if (($page == 'ipsandports' || $page == 'overview') && $userinfo['change_serversettings'] == '1') { if(isset($_POST['id']))
if ($action == '') { {
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_ipsandports"); $id = intval($_POST['id']);
}
elseif(isset($_GET['id']))
{
$id = intval($_GET['id']);
}
try { if($page == 'ipsandports'
$ipsandports_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.ipsandports.php'; || $page == 'overview')
$collection = (new Collection(IpsAndPorts::class, $userinfo)) {
->withPagination($ipsandports_list_data['ipsandports_list']['columns'], $ipsandports_list_data['ipsandports_list']['default_sorting']); if($action == '')
} catch (Exception $e) { {
Response::dynamicError($e->getMessage()); $log->logAction(ADM_ACTION, LOG_NOTICE, "viewed admin_ipsandports");
} $fields = array(
'ip' => $lng['admin']['ipsandports']['ip'],
'port' => $lng['admin']['ipsandports']['port']
);
$paging = new paging($userinfo, $db, TABLE_PANEL_IPSANDPORTS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
$ipsandports = '';
$result = $db->query("SELECT `id`, `ip`, `port`, `listen_statement`, `namevirtualhost_statement`, `vhostcontainer`, `vhostcontainer_servername_statement`, `specialsettings`, `ssl` FROM `" . TABLE_PANEL_IPSANDPORTS . "` " . $paging->getSqlWhere(false) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
$paging->setEntries($db->num_rows($result));
$sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$i = 0;
$count = 0;
UI::view('user/table.html.twig', [ while($row = $db->fetch_array($result))
'listing' => Listing::format($collection, $ipsandports_list_data, 'ipsandports_list'), {
'actions_links' => [ if($paging->checkDisplay($i))
[ {
'href' => $linker->getLink(['section' => 'ipsandports', 'page' => $page, 'action' => 'add']), $row = htmlentities_array($row);
'label' => lng('admin.ipsandports.add')
]
]
]);
} elseif ($action == 'delete' && $id != 0) {
try {
$json_result = IpsAndPorts::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(filter_var($row['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6))
if (isset($_POST['send']) && $_POST['send'] == 'send') { {
try { $row['ip'] = '[' . $row['ip'] . ']';
IpsAndPorts::getLocal($userinfo, [
'id' => $id
])->delete();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
} }
Response::redirectTo($filename, [ eval("\$ipsandports.=\"" . getTemplate("ipsandports/ipsandports_ipandport") . "\";");
'page' => $page $count++;
]);
} else {
HTML::askYesNo('admin_ip_reallydelete', $filename, [
'id' => $id,
'page' => $page,
'action' => $action
], $result['ip'] . ':' . $result['port']);
} }
}
} elseif ($action == 'add') {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
try {
IpsAndPorts::getLocal($userinfo, $_POST)->add();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
Response::redirectTo($filename, [
'page' => $page
]);
} else {
$ipsandports_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/ipsandports/formfield.ipsandports_add.php';
UI::view('user/form.html.twig', [ $i++;
'formaction' => $linker->getLink(['section' => 'ipsandports']),
'formdata' => $ipsandports_add_data['ipsandports_add']
]);
} }
} elseif ($action == 'edit' && $id != 0) {
try {
$json_result = IpsAndPorts::getLocal($userinfo, [
'id' => $id
])->get();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
if ($result['ip'] != '') { eval("echo \"" . getTemplate("ipsandports/ipsandports") . "\";");
if (isset($_POST['send']) && $_POST['send'] == 'send') { }
try { elseif($action == 'delete'
IpsAndPorts::getLocal($userinfo, $_POST)->update(); && $id != 0)
} catch (Exception $e) { {
Response::dynamicError($e->getMessage()); $result = $db->query_first("SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id`='" . (int)$id . "'");
if(isset($result['id'])
&& $result['id'] == $id)
{
$result_checkdomain = $db->query_first("SELECT `id` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `ipandport`='" . (int)$id . "'");
if($result_checkdomain['id'] == '')
{
if($result['id'] != $settings['system']['defaultip'])
{
$result_sameipotherport = $db->query_first("SELECT `id` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `ip`='" . $db->escape($result['ip']) . "' AND `id`!='" . (int)$id . "'");
if(($result['ip'] != $settings['system']['ipaddress'])
|| ($result['ip'] == $settings['system']['ipaddress'] && $result_sameipotherport['id'] != ''))
{
$result = $db->query_first("SELECT `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id`='" . (int)$id . "'");
if($result['ip'] != '')
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$db->query("DELETE FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id`='" . (int)$id . "'");
$log->logAction(ADM_ACTION, LOG_WARNING, "deleted IP/port '" . $result['ip'] . ":" . $result['port'] . "'");
inserttask('1');
inserttask('4');
redirectTo($filename, Array('page' => $page, 's' => $s));
}
else
{
ask_yesno('admin_ip_reallydelete', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $result['ip'] . ':' . $result['port']);
}
}
}
else
{
standard_error('cantdeletesystemip');
}
} }
Response::redirectTo($filename, [ else
'page' => $page {
]); standard_error('cantdeletedefaultip');
} else { }
$result = PhpHelper::htmlentitiesArray($result); }
else
$ipsandports_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/ipsandports/formfield.ipsandports_edit.php'; {
standard_error('ipstillhasdomains');
UI::view('user/form.html.twig', [
'formaction' => $linker->getLink(['section' => 'ipsandports', 'id' => $id]),
'formdata' => $ipsandports_edit_data['ipsandports_edit'],
'editid' => $id
]);
} }
} }
} elseif ($action == 'jqCheckIP') { }
$ip = $_POST['ip'] ?? ""; elseif($action == 'add')
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 if(isset($_POST['send'])
echo json_encode(lng('admin.ipsandports.ipnote')); && $_POST['send'] == 'send')
} else { {
echo 0; $ip = validate_ip($_POST['ip']);
$port = validate($_POST['port'], 'port', '/^(([1-9])|([1-9][0-9])|([1-9][0-9][0-9])|([1-9][0-9][0-9][0-9])|([1-5][0-9][0-9][0-9][0-9])|(6[0-4][0-9][0-9][0-9])|(65[0-4][0-9][0-9])|(655[0-2][0-9])|(6553[0-5]))$/Di', array('stringisempty', 'myport'));
$listen_statement = intval($_POST['listen_statement']);
$namevirtualhost_statement = intval($_POST['namevirtualhost_statement']);
$vhostcontainer = intval($_POST['vhostcontainer']);
$specialsettings = validate(str_replace("\r\n", "\n", $_POST['specialsettings']), 'specialsettings', '/^[^\0]*$/');
$vhostcontainer_servername_statement = intval($_POST['vhostcontainer_servername_statement']);
$ssl = intval($_POST['ssl']);
$ssl_cert_file = validate($_POST['ssl_cert_file'], 'ssl_cert_file');
$ssl_key_file = validate($_POST['ssl_key_file'], 'ssl_key_file');
$ssl_ca_file = validate($_POST['ssl_ca_file'], 'ssl_ca_file');
$default_vhostconf_domain = validate(str_replace("\r\n", "\n", $_POST['default_vhostconf_domain']), 'default_vhostconf_domain', '/^[^\0]*$/');
if($listen_statement != '1')
{
$listen_statement = '0';
}
if($namevirtualhost_statement != '1')
{
$namevirtualhost_statement = '0';
}
if($vhostcontainer != '1')
{
$vhostcontainer = '0';
}
if($vhostcontainer_servername_statement != '1')
{
$vhostcontainer_servername_statement = '0';
}
if($ssl != '1')
{
$ssl = '0';
}
if($ssl_cert_file != '')
{
$ssl_cert_file = makeCorrectFile($ssl_cert_file);
}
if($ssl_key_file != '')
{
$ssl_key_file = makeCorrectFile($ssl_key_file);
}
if($ssl_ca_file != '')
{
$ssl_ca_file = makeCorrectFile($ssl_ca_file);
}
$result_checkfordouble = $db->query_first("SELECT `id` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `ip`='" . $db->escape($ip) . "' AND `port`='" . (int)$port . "'");
if($result_checkfordouble['id'] != '')
{
standard_error('myipnotdouble');
}
else
{
$db->query("INSERT INTO `" . TABLE_PANEL_IPSANDPORTS . "` (`ip`, `port`, `listen_statement`, `namevirtualhost_statement`, `vhostcontainer`, `vhostcontainer_servername_statement`, `specialsettings`, `ssl`, `ssl_cert_file`, `ssl_key_file`, `ssl_ca_file`, `default_vhostconf_domain`) VALUES ('" . $db->escape($ip) . "', '" . (int)$port . "', '" . (int)$listen_statement . "', '" . (int)$namevirtualhost_statement . "', '" . (int)$vhostcontainer . "', '" . (int)$vhostcontainer_servername_statement . "', '" . $db->escape($specialsettings) . "', '" . (int)$ssl . "', '" . $db->escape($ssl_cert_file) . "', '" . $db->escape($ssl_key_file) . "', '" . $db->escape($ssl_ca_file) . "', '" . $db->escape($default_vhostconf_domain) . "')");
if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6))
{
$ip = '[' . $ip . ']';
}
$log->logAction(ADM_ACTION, LOG_WARNING, "added IP/port '" . $ip . ":" . $port . "'");
inserttask('1');
inserttask('4');
redirectTo($filename, Array('page' => $page, 's' => $s));
}
}
else
{
$enable_ssl = makeyesno('ssl', '1', '0', '0');
$listen_statement = makeyesno('listen_statement', '1', '0', '1');
$namevirtualhost_statement = makeyesno('namevirtualhost_statement', '1', '0', '1');
$vhostcontainer = makeyesno('vhostcontainer', '1', '0', '1');
$vhostcontainer_servername_statement = makeyesno('vhostcontainer_servername_statement', '1', '0', '1');
eval("echo \"" . getTemplate("ipsandports/ipsandports_add") . "\";");
}
}
elseif($action == 'edit'
&& $id != 0)
{
$result = $db->query_first("SELECT * FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id`='" . (int)$id . "'");
if($result['ip'] != '')
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$ip = validate_ip($_POST['ip']);
$port = validate($_POST['port'], 'port', '/^(([1-9])|([1-9][0-9])|([1-9][0-9][0-9])|([1-9][0-9][0-9][0-9])|([1-5][0-9][0-9][0-9][0-9])|(6[0-4][0-9][0-9][0-9])|(65[0-4][0-9][0-9])|(655[0-2][0-9])|(6553[0-5]))$/Di', array('stringisempty', 'myport'));
$result_checkfordouble = $db->query_first("SELECT `id` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `ip`='" . $db->escape($ip) . "' AND `port`='" . (int)$port . "'");
$result_sameipotherport = $db->query_first("SELECT `id` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `ip`='" . $db->escape($result['ip']) . "' AND `id`!='" . (int)$id . "'");
$listen_statement = intval($_POST['listen_statement']);
$namevirtualhost_statement = intval($_POST['namevirtualhost_statement']);
$vhostcontainer = intval($_POST['vhostcontainer']);
$specialsettings = validate(str_replace("\r\n", "\n", $_POST['specialsettings']), 'specialsettings', '/^[^\0]*$/');
$vhostcontainer_servername_statement = intval($_POST['vhostcontainer_servername_statement']);
$ssl = intval($_POST['ssl']);
$ssl_cert_file = validate($_POST['ssl_cert_file'], 'ssl_cert_file');
$ssl_key_file = validate($_POST['ssl_key_file'], 'ssl_key_file');
$ssl_ca_file = validate($_POST['ssl_ca_file'], 'ssl_ca_file');
$default_vhostconf_domain = validate(str_replace("\r\n", "\n", $_POST['default_vhostconf_domain']), 'default_vhostconf_domain', '/^[^\0]*$/');
if($listen_statement != '1')
{
$listen_statement = '0';
}
if($namevirtualhost_statement != '1')
{
$namevirtualhost_statement = '0';
}
if($vhostcontainer != '1')
{
$vhostcontainer = '0';
}
if($vhostcontainer_servername_statement != '1')
{
$vhostcontainer_servername_statement = '0';
}
if($ssl != '1')
{
$ssl = '0';
}
if($ssl_cert_file != '')
{
$ssl_cert_file = makeCorrectFile($ssl_cert_file);
}
if($ssl_key_file != '')
{
$ssl_key_file = makeCorrectFile($ssl_key_file);
}
if($ssl_ca_file != '')
{
$ssl_ca_file = makeCorrectFile($ssl_ca_file);
}
if($result['ip'] != $ip
&& $result['ip'] == $settings['system']['ipaddress']
&& $result_sameipotherport['id'] == '')
{
standard_error('cantchangesystemip');
}
elseif($result_checkfordouble['id'] != ''
&& $result_checkfordouble['id'] != $id)
{
standard_error('myipnotdouble');
}
else
{
$db->query("UPDATE `" . TABLE_PANEL_IPSANDPORTS . "` SET `ip`='" . $db->escape($ip) . "', `port`='" . (int)$port . "', `listen_statement`='" . (int)$listen_statement . "', `namevirtualhost_statement`='" . (int)$namevirtualhost_statement . "', `vhostcontainer`='" . (int)$vhostcontainer . "', `vhostcontainer_servername_statement`='" . (int)$vhostcontainer_servername_statement . "', `specialsettings`='" . $db->escape($specialsettings) . "', `ssl`='" . (int)$ssl . "', `ssl_cert_file`='" . $db->escape($ssl_cert_file) . "', `ssl_key_file`='" . $db->escape($ssl_key_file) . "', `ssl_ca_file`='" . $db->escape($ssl_ca_file) . "', `default_vhostconf_domain`='" . $db->escape($default_vhostconf_domain) . "' WHERE `id`='" . (int)$id . "'");
$log->logAction(ADM_ACTION, LOG_WARNING, "changed IP/port from '" . $result['ip'] . ":" . $result['port'] . "' to '" . $ip . ":" . $port . "'");
inserttask('1');
inserttask('4');
redirectTo($filename, Array('page' => $page, 's' => $s));
}
}
else
{
$enable_ssl = makeyesno('ssl', '1', '0', $result['ssl']);
$result = htmlentities_array($result);
$listen_statement = makeyesno('listen_statement', '1', '0', $result['listen_statement']);
$namevirtualhost_statement = makeyesno('namevirtualhost_statement', '1', '0', $result['namevirtualhost_statement']);
$vhostcontainer = makeyesno('vhostcontainer', '1', '0', $result['vhostcontainer']);
$vhostcontainer_servername_statement = makeyesno('vhostcontainer_servername_statement', '1', '0', $result['vhostcontainer_servername_statement']);
eval("echo \"" . getTemplate("ipsandports/ipsandports_edit") . "\";");
}
} }
exit();
} }
} }
?>

View File

@@ -2,75 +2,170 @@
/** /**
* 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 * @version $Id$
* 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'; define('AREA', 'admin');
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\SysLog; /**
use Froxlor\UI\Collection; * Include our init.php, which manages Sessions, Language etc.
use Froxlor\UI\HTML; */
use Froxlor\UI\Listing;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Response;
if ($page == 'log' && $userinfo['change_serversettings'] == '1') { require ("./lib/init.php");
if ($action == '') {
try { if($page == 'log'
$syslog_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/tablelisting.syslog.php'; && $userinfo['change_serversettings'] == '1')
$collection = (new Collection(SysLog::class, $userinfo)) {
->withPagination($syslog_list_data['syslog_list']['columns'], $syslog_list_data['syslog_list']['default_sorting']); if($action == '')
} catch (Exception $e) { {
Response::dynamicError($e->getMessage()); $fields = array(
'action' => $lng['logger']['action'],
'date' => $lng['logger']['date'],
'type' => $lng['logger']['type'],
'user' => $lng['logger']['user']
);
$paging = new paging($userinfo, $db, TABLE_PANEL_LOG, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
$paging->sortfield = 'date';
$paging->sortorder = 'desc';
$result = $db->query('SELECT * FROM `' . TABLE_PANEL_LOG . '` ' . $paging->getSqlWhere(false) . ' ' . $paging->getSqlOrderBy() . ' ' . $paging->getSqlLimit());
$paging->setEntries($db->num_rows($result));
$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();
while($row = $db->fetch_array($result))
{
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'
'listing' => Listing::format($collection, $syslog_list_data, 'syslog_list'), && $paging->sortorder == 'desc')
'actions_links' => [ {
[ krsort($clog);
'href' => $linker->getLink(['section' => 'logger', 'page' => 'log', 'action' => 'truncate']), }
'label' => lng('logger.truncate'), else
'icon' => 'fa-solid fa-recycle', {
'class' => 'btn-warning' ksort($clog);
] }
]
]); $i = 0;
} elseif ($action == 'truncate') { $count = 0;
if (isset($_POST['send']) && $_POST['send'] == 'send') { $log_count = 0;
try { $log = '';
SysLog::getLocal($userinfo, [ foreach($clog as $action => $logrows)
'min_to_keep' => 10 {
])->delete(); $_action = 0;
} catch (Exception $e) { foreach($logrows as $row)
Response::dynamicError($e->getMessage()); {
if($paging->checkDisplay($i))
{
$row = htmlentities_array($row);
$row['date'] = date("d.m.y H:i:s", $row['date']);
if($_action != $action)
{
switch($action)
{
case USR_ACTION:
$_action = $lng['admin']['customer'];
break;
case RES_ACTION:
$_action = 'Reseller';
break;
case ADM_ACTION:
$_action = 'Administrator';
break;
case CRON_ACTION:
$_action = 'Cronjob';
break;
case LOG_ERROR:
$_action = 'Internal';
break;
default:
$_action = 'Unknown';
break;
}
$row['action'] = $_action;
eval("\$log.=\"" . getTemplate("logger/logger_action") . "\";");
}
$log_count++;
$type = $row['type'];
$_type = 'unknown';
switch($type)
{
case LOG_INFO:
$_type = 'Information';
break;
case LOG_NOTICE:
$_type = 'Notice';
break;
case LOG_WARNING:
$_type = 'Warning';
break;
case LOG_ERR:
$_type = 'Error';
break;
case LOG_CRIT:
$_type = 'Critical';
break;
default:
$_type = 'Unknown';
break;
}
$row['type'] = $_type;
eval("\$log.=\"" . getTemplate("logger/logger_log") . "\";");
$count++;
$_action = $action;
}
} }
Response::redirectTo($filename, [
'page' => $page $i++;
]); }
} else {
HTML::askYesNo('logger_reallytruncate', $filename, [ eval("echo \"" . getTemplate("logger/logger") . "\";");
'page' => $page, }
'action' => $action elseif($action == 'truncate')
], TABLE_PANEL_LOG); {
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$yesterday = time() - (60 * 10);
/* (60*60*24); */
$db->query("DELETE FROM `" . TABLE_PANEL_LOG . "` WHERE `date` < '" . $yesterday . "'");
$log->logAction(ADM_ACTION, LOG_WARNING, "truncated the system-log (mysql)");
redirectTo($filename, Array('page' => $page, 's' => $s));
}
else
{
ask_yesno('logger_reallytruncate', $filename, array('page' => $page, 'action' => $action), TABLE_PANEL_LOG);
} }
} }
} }
?>

View File

@@ -2,149 +2,147 @@
/** /**
* 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 * @version $Id$
* 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'; define('AREA', 'admin');
require __DIR__ . '/lib/init.php';
use Froxlor\Database\Database; /**
use Froxlor\FroxlorLogger; * Include our init.php, which manages Sessions, Language etc.
use Froxlor\UI\Panel\UI; */
use Froxlor\UI\Request;
use Froxlor\UI\Response;
use Froxlor\User;
$id = (int)Request::any('id'); require ("./lib/init.php");
$note_type = null; if(isset($_POST['id']))
$note_msg = null; {
$id = intval($_POST['id']);
}
elseif(isset($_GET['id']))
{
$id = intval($_GET['id']);
}
if ($page == 'message') { if($page == 'message')
if ($action == '') { {
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'viewed panel_message'); if($action == '')
{
$log->logAction(ADM_ACTION, LOG_NOTICE, "viewed panel_message");
if (isset($_POST['send']) && $_POST['send'] == 'send') { if(isset($_POST['send'])
if ($_POST['recipient'] == 0 && $userinfo['customers_see_all'] == '1') { && $_POST['send'] == 'send')
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'sending messages to admins'); {
$result = Database::query('SELECT `name`, `email` FROM `' . TABLE_PANEL_ADMINS . "`"); if($_POST['receipient'] == 0
} elseif ($_POST['recipient'] == 1) { && $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(ADM_ACTION, LOG_NOTICE, "sending messages to admins");
$result = Database::query('SELECT `firstname`, `name`, `company`, `email` FROM `' . TABLE_PANEL_CUSTOMERS . "`"); $result = $db->query('SELECT `firstname`, `name`, `email` FROM `' . TABLE_PANEL_ADMINS . "`");
} else { }
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'sending messages to customers'); elseif($_POST['receipient'] == 1)
$result = Database::prepare(' {
SELECT `firstname`, `name`, `company`, `email` FROM `' . TABLE_PANEL_CUSTOMERS . "` if($userinfo['customers_see_all'] == "1")
WHERE `adminid` = :adminid"); {
Database::pexecute($result, [ $log->logAction(ADM_ACTION, LOG_NOTICE, "sending messages to ALL customers");
'adminid' => $userinfo['adminid'] $result = $db->query('SELECT `firstname`, `name`, `email` FROM `' . TABLE_PANEL_CUSTOMERS . "`");
]);
} }
} else { else
Response::standardError('norecipientsgiven'); {
$log->logAction(ADM_ACTION, LOG_NOTICE, "sending messages to customers");
$result = $db->query('SELECT `firstname`, `name`, `email` FROM `' . TABLE_PANEL_CUSTOMERS . "` WHERE `adminid`='" . $userinfo['adminid'] . "'");
}
}
else
{
standard_error('noreceipientsgiven');
} }
$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 = $db->fetch_array($result))
$row['firstname'] = isset($row['firstname']) ? $row['firstname'] : ''; {
$row['company'] = isset($row['company']) ? $row['company'] : ''; $mail->AddAddress($row['email'], $row['firstname'] . ' ' . $row['name']);
$mail->AddAddress($row['email'], User::getCorrectUserSalutation([
'firstname' => $row['firstname'],
'name' => $row['name'],
'company' => $row['company']
]));
$mail->From = $userinfo['email']; $mail->From = $userinfo['email'];
$mail->FromName = (isset($userinfo['firstname']) ? $userinfo['firstname'] . ' ' : '') . $userinfo['name']; $mail->FromName = $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 { }
$mailerr_msg = $row['email']; else
{
$mailerr_msg = $row["email"];
} }
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_ERR, 'Error sending mail: ' . $mailerr_msg); $log->logAction(ADM_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg);
Response::standardError('errorsendingmail', $row['email']); standard_error('errorsendingmail', $row["email"]);
} }
$mailcounter++; $mailcounter++;
$mail->ClearAddresses(); $mail->ClearAddresses();
} }
Response::redirectTo($filename, [ redirectTo($filename, Array('page' => $page, 's' => $s, 'action' => 'showsuccess', 'sentitems' => $mailcounter));
'page' => $page, }
'action' => 'showsuccess', else
'sentitems' => $mailcounter {
]); standard_error('nomessagetosend');
} else {
Response::standardError('nomessagetosend');
} }
} }
} elseif ($action == 'showsuccess') { }
if($action == 'showsuccess')
{
$success = 1;
$sentitems = isset($_GET['sentitems']) ? (int)$_GET['sentitems'] : 0; $sentitems = isset($_GET['sentitems']) ? (int)$_GET['sentitems'] : 0;
if ($sentitems == 0) { if($sentitems == 0)
$note_type = 'info'; {
$note_msg = lng('message.norecipients'); $successmessage = $lng['message']['noreceipients'];
} else {
$note_type = 'success';
$note_msg = str_replace('%s', $sentitems, lng('message.success'));
} }
else
{
$successmessage = str_replace('%s', $sentitems, $lng['message']['success']);
}
$action = '';
}
else
{
$success = 0;
$sentitems = 0;
$successmessage = '';
$action = '';
} }
$recipients = []; $receipients = '';
if ($userinfo['customers_see_all'] == '1') { if($userinfo['customers_see_all'] == "1")
$recipients[0] = lng('panel.reseller'); {
$receipients.= 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'; $receipients.= makeoption($lng['panel']['customer'], 1);
eval("echo \"" . 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

@@ -1,308 +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>
* @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/
*/
const AREA = 'admin';
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 ($_POST['send'] == 'send') {
opcache_reset();
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "reset OPcache");
header('Location: ' . $linker->getLink([
'section' => 'opcacheinfo',
'page' => 'showinfo'
]));
exit();
} else {
HTML::askYesNo('cache_reallydelete', $filename, [
'page' => $page,
'action' => 'reset',
], '', [
'section' => 'opcacheinfo',
'page' => 'showinfo'
]);
}
}
if (!function_exists('opcache_get_configuration')) {
Response::standardError(lng('error.no_opcacheinfo'));
}
if ($page == 'showinfo' && $userinfo['change_serversettings'] == '1') {
$time = time();
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed OPcache info");
$optimizationLevels = [
1 << 0 => 'CSE, STRING construction',
1 << 1 => 'Constant conversion and jumps',
1 << 2 => '++, +=, series of jumps',
1 << 3 => 'INIT_FCALL_BY_NAME -> DO_FCALL',
1 << 4 => 'CFG based optimization',
1 << 5 => 'DFA based optimization',
1 << 6 => 'CALL GRAPH optimization',
1 << 7 => 'SCCP (constant propagation)',
1 << 8 => 'TMP VAR usage',
1 << 9 => 'NOP removal',
1 << 10 => 'Merge equal constants',
1 << 11 => 'Adjust used stack',
1 << 12 => 'Remove unused variables',
1 << 13 => 'DCE (dead code elimination)',
1 << 14 => '(unsafe) Collect constants',
1 << 15 => 'Inline functions'
];
$jitModes = [
[
'flag' => 'CPU-specific optimization',
'value' => [
'Disable CPU-specific optimization',
'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'])) {
$overview['readable']['interned'] = [
'buffer_size' => bsize($status['interned_strings_usage']['buffer_size']),
'strings_used_memory' => bsize($status['interned_strings_usage']['used_memory']),
'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'])) {
$overview['jit_buffer_used_percentage'] = ($status['jit']['buffer_size']
? round(100 * (($status['jit']['buffer_size'] - $status['jit']['buffer_free']) / $status['jit']['buffer_size']))
: 0
);
$overview['readable'] = array_merge($overview['readable'], [
'jit_buffer_size' => bsize($status['jit']['buffer_size']),
'jit_buffer_free' => bsize($status['jit']['buffer_free'])
]);
}
$directives = [];
ksort($config['directives']);
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', [
'opcacheinfo' => [
'version' => $version,
'overview' => $overview,
'files' => $files,
'preload' => $preload,
'directives' => $directives,
'blacklist' => $config['blacklist'],
'functions' => get_extension_funcs('Zend OPcache')
]
]);
}
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',
$size,
'',
$val[$i]
);
}

View File

@@ -2,296 +2,184 @@
/** /**
* 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 * @version $Id$
* 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'; define('AREA', 'admin');
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\FpmDaemons; /**
use Froxlor\Api\Commands\PhpSettings; * Include our init.php, which manages Sessions, Language etc.
use Froxlor\Database\Database; */
use Froxlor\Froxlor;
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'); require ("./lib/init.php");
if ($page == 'overview') { if(isset($_POST['id']))
if ($action == '') { {
try { $id = intval($_POST['id']);
$phpconf_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.phpconfigs.php'; }
$collection = (new Collection(PhpSettings::class, $userinfo, ['with_subdomains' => true])) elseif(isset($_GET['id']))
->withPagination($phpconf_list_data['phpconf_list']['columns'], $phpconf_list_data['phpconf_list']['default_sorting']); {
} catch (Exception $e) { $id = intval($_GET['id']);
Response::dynamicError($e->getMessage()); }
}
UI::view('user/table.html.twig', [ if($page == 'overview')
'listing' => Listing::format($collection, $phpconf_list_data, 'phpconf_list'), {
'actions_links' => (bool)$userinfo['change_serversettings'] ? [ if($action == '')
[ {
'href' => $linker->getLink(['section' => 'phpsettings', 'page' => $page, 'action' => 'add']), $tablecontent = '';
'label' => lng('admin.phpsettings.addnew') $result = $db->query("SELECT * FROM `" . TABLE_PANEL_PHPCONFIGS . "`");
]
] : []
]);
}
if ($action == 'add') { while($row = $db->fetch_array($result))
if ((int)$userinfo['change_serversettings'] == 1) {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
try {
PhpSettings::getLocal($userinfo, $_POST)->add();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
Response::redirectTo($filename, [
'page' => $page
]);
} else {
if (file_exists(Froxlor::getInstallDir() . '/templates/misc/php/default.ini.php')) {
include Froxlor::getInstallDir() . '/templates/misc/php/default.ini.php';
$result = [
'phpsettings' => $phpini
];
} else {
// use first php-config as fallback
$result_stmt = Database::query("SELECT * FROM `" . TABLE_PANEL_PHPCONFIGS . "` WHERE `id` = 1");
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
}
$fpmconfigs = [];
$configs = Database::query("SELECT * FROM `" . TABLE_PANEL_FPMDAEMONS . "` ORDER BY `description` ASC");
while ($row = $configs->fetch(PDO::FETCH_ASSOC)) {
$fpmconfigs[$row['id']] = $row['description'];
}
$phpconfig_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/phpconfig/formfield.phpconfig_add.php';
UI::view('user/form-replacers.html.twig', [
'formaction' => $linker->getLink(['section' => 'phpsettings']),
'formdata' => $phpconfig_add_data['phpconfig_add'],
'replacers' => $phpconfig_add_data['phpconfig_replacers']
]);
}
} else {
Response::standardError('nopermissionsorinvalidid');
}
}
if ($action == 'delete') {
try {
$json_result = PhpSettings::getLocal($userinfo, [
'id' => $id
])->get();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
$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 (isset($_POST['send']) && $_POST['send'] == 'send') { $domainresult = false;
try {
PhpSettings::getLocal($userinfo, [ if((int)$userinfo['domains_see_all'] == 0)
'id' => $id {
])->delete(); $domainresult = $db->query("SELECT * FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `adminid` = " . (int)$userinfo['userid'] . " AND `phpsettingid` = " . (int)$row['id']);
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
Response::redirectTo($filename, [
'page' => $page
]);
} else {
HTML::askYesNo('phpsetting_reallydelete', $filename, [
'id' => $id,
'page' => $page,
'action' => $action
], $result['description']);
} }
} else { else
Response::standardError('nopermissionsorinvalidid'); {
} $domainresult = $db->query("SELECT * FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `phpsettingid` = " . (int)$row['id']);
}
if ($action == 'edit') {
try {
$json_result = PhpSettings::getLocal($userinfo, [
'id' => $id
])->get();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
if ($result['id'] != 0 && $result['id'] == $id && (int)$userinfo['change_serversettings'] == 1) {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
try {
PhpSettings::getLocal($userinfo, $_POST)->update();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
Response::redirectTo($filename, [
'page' => $page
]);
} else {
$fpmconfigs = [];
$configs = Database::query("SELECT * FROM `" . TABLE_PANEL_FPMDAEMONS . "` ORDER BY `description` ASC");
while ($row = $configs->fetch(PDO::FETCH_ASSOC)) {
$fpmconfigs[$row['id']] = $row['description'];
}
$phpconfig_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/phpconfig/formfield.phpconfig_edit.php';
UI::view('user/form-replacers.html.twig', [
'formaction' => $linker->getLink(['section' => 'phpsettings', 'id' => $id]),
'formdata' => $phpconfig_edit_data['phpconfig_edit'],
'replacers' => $phpconfig_edit_data['phpconfig_replacers'],
'editid' => $id
]);
} }
} else {
Response::standardError('nopermissionsorinvalidid');
}
}
} 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', [ $domains = '';
'listing' => Listing::format($collection, $fpmconf_list_data, 'fpmconf_list'),
'actions_links' => (bool)$userinfo['change_serversettings'] ? [
[
'href' => $linker->getLink(['section' => 'phpsettings', 'page' => $page, 'action' => 'add']),
'label' => lng('admin.fpmsettings.addnew')
]
] : []
]);
}
if ($action == 'add') { if($db->num_rows($domainresult) > 0)
if ((int)$userinfo['change_serversettings'] == 1) { {
if (isset($_POST['send']) && $_POST['send'] == 'send') { while($row2 = $db->fetch_array($domainresult))
try { {
FpmDaemons::getLocal($userinfo, $_POST)->add(); $domains.= $row2['domain'] . '<br/>';
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
} }
Response::redirectTo($filename, [
'page' => $page
]);
} else {
$fpmconfig_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/phpconfig/formfield.fpmconfig_add.php';
UI::view('user/form-replacers.html.twig', [
'formaction' => $linker->getLink(['section' => 'phpsettings', 'page' => 'fpmdaemons']),
'formdata' => $fpmconfig_add_data['fpmconfig_add'],
'replacers' => $fpmconfig_add_data['fpmconfig_replacers']
]);
} }
} else { else
Response::standardError('nopermissionsorinvalidid'); {
$domains = $lng['admin']['phpsettings']['notused'];
}
eval("\$tablecontent.=\"" . getTemplate("phpconfig/overview_overview") . "\";");
} }
$log->logAction(ADM_ACTION, LOG_INFO, "php.ini setting overview has been viewed by '" . $userinfo['loginname'] . "'");
eval("echo \"" . getTemplate("phpconfig/overview") . "\";");
} }
if ($action == 'delete') { if($action == 'add')
try { {
$json_result = FpmDaemons::getLocal($userinfo, [ if((int)$userinfo['change_serversettings'] == 1)
'id' => $id
])->get();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
if ($id == 1) {
Response::standardError('cannotdeletedefaultphpconfig');
}
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'])
try { && $_POST['send'] == 'send')
FpmDaemons::getLocal($userinfo, $_POST)->delete(); {
} catch (Exception $e) { $description = validate($_POST['description'], 'description');
Response::dynamicError($e->getMessage()); $binary = makeCorrectFile(validate($_POST['binary'], 'binary'));
$file_extensions = validate($_POST['file_extensions'], 'file_extensions', '/^[a-zA-Z0-9\s]*$/');
$phpsettings = validate(str_replace("\r\n", "\n", $_POST['phpsettings']), 'phpsettings', '/^[^\0]*$/');
$mod_fcgid_starter = validate($_POST['mod_fcgid_starter'], 'mod_fcgid_starter', '/^[0-9]*$/', '', array('-1', ''));
$mod_fcgid_maxrequests = validate($_POST['mod_fcgid_maxrequests'], 'mod_fcgid_maxrequests', '/^[0-9]*$/', '', array('-1', ''));
if(strlen($description) == 0
|| strlen($description) > 50)
{
standard_error('descriptioninvalid');
} }
Response::redirectTo($filename, [
'page' => $page $db->query("INSERT INTO `" . TABLE_PANEL_PHPCONFIGS . "` SET `description` = '" . $db->escape($description) . "', `binary` = '" . $db->escape($binary) . "', `file_extensions` = '" . $db->escape($file_extensions) . "', `mod_fcgid_starter` = '" . $db->escape($mod_fcgid_starter) . "', `mod_fcgid_maxrequests` = '" . $db->escape($mod_fcgid_maxrequests) . "', `phpsettings` = '" . $db->escape($phpsettings) . "'");
]); inserttask('1');
} else { $log->logAction(ADM_ACTION, LOG_INFO, "php.ini setting with description '" . $value . "' has been created by '" . $userinfo['loginname'] . "'");
HTML::askYesNo('fpmsetting_reallydelete', $filename, [ redirectTo($filename, Array('page' => $page, 's' => $s));
'id' => $id,
'page' => $page,
'action' => $action
], $result['description']);
} }
} else { else
Response::standardError('nopermissionsorinvalidid'); {
$result = $db->query_first("SELECT * FROM `" . TABLE_PANEL_PHPCONFIGS . "` WHERE `id` = 1");
eval("echo \"" . getTemplate("phpconfig/overview_add") . "\";");
}
}
else
{
standard_error('nopermissionsorinvalidid');
} }
} }
if ($action == 'edit') { if($action == 'delete')
try { {
$json_result = FpmDaemons::getLocal($userinfo, [ $result = $db->query_first("SELECT * FROM `" . TABLE_PANEL_PHPCONFIGS . "` WHERE `id` = " . (int)$id);
'id' => $id
])->get();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
if ($result['id'] != 0 && $result['id'] == $id && (int)$userinfo['change_serversettings'] == 1) { if($result['id'] != 0
if (isset($_POST['send']) && $_POST['send'] == 'send') { && $result['id'] == $id
try { && (int)$userinfo['change_serversettings'] == 1
FpmDaemons::getLocal($userinfo, $_POST)->update(); && $id != 1)
} catch (Exception $e) { {
Response::dynamicError($e->getMessage()); if(isset($_POST['send'])
} && $_POST['send'] == 'send')
Response::redirectTo($filename, [ {
'page' => $page $db->query("UPDATE `" . TABLE_PANEL_DOMAINS . "` SET `phpsettingid` = 1 WHERE `phpsettingid` = " . (int)$id);
]); $db->query("DELETE FROM `" . TABLE_PANEL_PHPCONFIGS . "` WHERE `id` = " . (int)$id);
} else { inserttask('1');
$fpmconfig_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/phpconfig/formfield.fpmconfig_edit.php'; $log->logAction(ADM_ACTION, LOG_INFO, "php.ini setting with id #" . (int)$id . " has been deleted by '" . $userinfo['loginname'] . "'");
redirectTo($filename, Array('page' => $page, 's' => $s));
UI::view('user/form-replacers.html.twig', [
'formaction' => $linker->getLink(['section' => 'phpsettings', 'page' => 'fpmdaemons', 'id' => $id]),
'formdata' => $fpmconfig_edit_data['fpmconfig_edit'],
'replacers' => $fpmconfig_edit_data['fpmconfig_replacers'],
'editid' => $id
]);
} }
} else { else
Response::standardError('nopermissionsorinvalidid'); {
ask_yesno('phpsetting_reallydelete', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $result['description']);
}
}
else
{
standard_error('nopermissionsorinvalidid');
}
}
if($action == 'edit')
{
$result = $db->query_first("SELECT * FROM `" . TABLE_PANEL_PHPCONFIGS . "` WHERE `id` = " . (int)$id);
if($result['id'] != 0
&& $result['id'] == $id
&& (int)$userinfo['change_serversettings'] == 1)
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$description = validate($_POST['description'], 'description');
$binary = makeCorrectFile(validate($_POST['binary'], 'binary'));
$file_extensions = validate($_POST['file_extensions'], 'file_extensions', '/^[a-zA-Z0-9\s]*$/');
$phpsettings = validate(str_replace("\r\n", "\n", $_POST['phpsettings']), 'phpsettings', '/^[^\0]*$/');
$mod_fcgid_starter = validate($_POST['mod_fcgid_starter'], 'mod_fcgid_starter', '/^[0-9]*$/', '', array('-1', ''));
$mod_fcgid_maxrequests = validate($_POST['mod_fcgid_maxrequests'], 'mod_fcgid_maxrequests', '/^[0-9]*$/', '', array('-1', ''));
if(strlen($description) == 0
|| strlen($description) > 50)
{
standard_error('descriptioninvalid');
}
$db->query("UPDATE `" . TABLE_PANEL_PHPCONFIGS . "` SET `description` = '" . $db->escape($description) . "', `binary` = '" . $db->escape($binary) . "', `file_extensions` = '" . $db->escape($file_extensions) . "', `mod_fcgid_starter` = '" . $db->escape($mod_fcgid_starter) . "', `mod_fcgid_maxrequests` = '" . $db->escape($mod_fcgid_maxrequests) . "', `phpsettings` = '" . $db->escape($phpsettings) . "' WHERE `id` = " . (int)$id);
inserttask('1');
$log->logAction(ADM_ACTION, LOG_INFO, "php.ini setting with description '" . $description . "' has been changed by '" . $userinfo['loginname'] . "'");
redirectTo($filename, Array('page' => $page, 's' => $s));
}
else
{
eval("echo \"" . getTemplate("phpconfig/overview_edit") . "\";");
}
}
else
{
standard_error('nopermissionsorinvalidid');
} }
} }
} }
?>

View File

@@ -1,278 +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\HostingPlans;
use Froxlor\Api\Commands\MysqlServer;
use Froxlor\Database\Database;
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;
$id = (int)Request::any('id');
if ($page == '' || $page == 'overview') {
if ($action == '') {
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_plans");
try {
$plan_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.plans.php';
$collection = (new Collection(HostingPlans::class, $userinfo))
->withPagination($plan_list_data['plan_list']['columns'], $plan_list_data['plan_list']['default_sorting']);
} catch (Exception $e) {
Response::dynamicError($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'];
if ($result['id'] != 0 && $result['id'] == $id && (int)$userinfo['adminid'] == $result['adminid']) {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
try {
HostingPlans::getLocal($userinfo, [
'id' => $id
])->delete();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
Response::redirectTo($filename, [
'page' => $page
]);
} else {
HTML::askYesNo('plan_reallydelete', $filename, [
'id' => $id,
'page' => $page,
'action' => $action
], $result['name']);
}
} else {
Response::standardError('nopermissionsorinvalidid');
}
} elseif ($action == 'add') {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
try {
HostingPlans::getLocal($userinfo, $_POST)->add();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
Response::redirectTo($filename, [
'page' => $page
]);
} 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 = [];
$configs = Database::query("
SELECT c.*, fc.description as interpreter
FROM `" . TABLE_PANEL_PHPCONFIGS . "` c
LEFT JOIN `" . TABLE_PANEL_FPMDAEMONS . "` fc ON fc.id = c.fpmsettingid
");
while ($row = $configs->fetch(PDO::FETCH_ASSOC)) {
if ((int)Settings::Get('phpfpm.enabled') == 1) {
$phpconfigs[] = [
'label' => $row['description'] . " [" . $row['interpreter'] . "]",
'value' => $row['id']
];
} else {
$phpconfigs[] = [
'label' => $row['description'],
'value' => $row['id']
];
}
}
// dummy to avoid unknown variables
$hosting_plans = null;
$plans_add_data = include_once __DIR__ . '/lib/formfields/admin/plans/formfield.plans_add.php';
$cust_add_data = include_once __DIR__ . '/lib/formfields/admin/customer/formfield.customer_add.php';
// unset unneeded stuff
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_cpre']);
// merge
$plans_add_data['plans_add']['sections'] = array_merge($plans_add_data['plans_add']['sections'], $cust_add_data['customer_add']['sections']);
UI::view('user/form.html.twig', [
'formaction' => $linker->getLink(['section' => 'plans']),
'formdata' => $plans_add_data['plans_add']
]);
}
} elseif ($action == 'edit' && $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'];
if ($result['name'] != '') {
$result['value'] = json_decode($result['value'], true);
$result = PhpHelper::htmlentitiesArray($result);
foreach ($result['value'] as $index => $value) {
$result[$index] = $value;
}
$result['allowed_phpconfigs'] = json_encode($result['allowed_phpconfigs']);
if (isset($_POST['send']) && $_POST['send'] == 'send') {
try {
HostingPlans::getLocal($userinfo, $_POST)->update();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
Response::redirectTo($filename, [
'page' => $page
]);
} 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 = [];
$configs = Database::query("
SELECT c.*, fc.description as interpreter
FROM `" . TABLE_PANEL_PHPCONFIGS . "` c
LEFT JOIN `" . TABLE_PANEL_FPMDAEMONS . "` fc ON fc.id = c.fpmsettingid
");
while ($row = $configs->fetch(PDO::FETCH_ASSOC)) {
if ((int)Settings::Get('phpfpm.enabled') == 1) {
$phpconfigs[] = [
'label' => $row['description'] . " [" . $row['interpreter'] . "]",
'value' => $row['id']
];
} else {
$phpconfigs[] = [
'label' => $row['description'],
'value' => $row['id']
];
}
}
$result['imap'] = $result['email_imap'];
$result['pop3'] = $result['email_pop3'];
// dummy to avoid unknown variables
$result['loginname'] = null;
$result['documentroot'] = null;
$result['standardsubdomain'] = null;
$result['deactivated'] = null;
$result['def_language'] = null;
$result['firstname'] = null;
$result['gender'] = null;
$result['company'] = null;
$result['street'] = null;
$result['zipcode'] = null;
$result['city'] = null;
$result['phone'] = null;
$result['fax'] = null;
$result['email'] = null;
$result['customernumber'] = null;
$result['custom_notes'] = null;
$result['custom_notes_show'] = null;
$result['api_allowed'] = null;
$hosting_plans = null;
$admin_select = [];
$plans_edit_data = include_once __DIR__ . '/lib/formfields/admin/plans/formfield.plans_edit.php';
$cust_edit_data = include_once __DIR__ . '/lib/formfields/admin/customer/formfield.customer_edit.php';
// unset unneeded stuff
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_cpre']);
unset($cust_edit_data['customer_edit']['sections']['section_d']);
// merge
$plans_edit_data['plans_edit']['sections'] = array_merge($plans_edit_data['plans_edit']['sections'], $cust_edit_data['customer_edit']['sections']);
UI::view('user/form.html.twig', [
'formaction' => $linker->getLink(['section' => 'plans', 'id' => $id]),
'formdata' => $plans_edit_data['plans_edit'],
'editid' => $id
]);
}
}
} elseif ($action == 'jqGetPlanValues') {
$planid = (int)Request::any('planid', 0);
try {
$json_result = HostingPlans::getLocal($userinfo, [
'id' => $planid
])->get();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
echo $result['value'];
exit();
}
}

View File

@@ -2,426 +2,160 @@
/** /**
* 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 * @version $Id$
* 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; define('AREA', 'admin');
use Froxlor\Cron\TaskId;
use Froxlor\Database\Database;
use Froxlor\Database\IntegrityCheck;
use Froxlor\FroxlorLogger;
use Froxlor\PhpHelper;
use Froxlor\Settings;
use Froxlor\System\Cronjob;
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'; /**
require __DIR__ . '/lib/init.php'; * Include our init.php, which manages Sessions, Language etc.
*/
// get sql-root access data $need_db_sql_data = true;
Database::needRoot(true); $need_root_db_sql_data = true;
Database::needSqlData(); require ("./lib/init.php");
$sql_root = Database::getSqlData();
Database::needRoot(false);
if ($page == 'overview' && $userinfo['change_serversettings'] == '1') { if(($page == 'settings' || $page == 'overview')
$settings_data = PhpHelper::loadConfigArrayDir('./actions/admin/settings/'); && $userinfo['change_serversettings'] == '1')
Settings::loadSettingsInto($settings_data); {
$settings_data = loadConfigArrayDir('./actions/admin/settings/');
if (isset($_POST['send']) && $_POST['send'] == 'send') { $settings = loadSettings(&$settings_data, &$db);
$_part = isset($_GET['part']) ? $_GET['part'] : '';
if ($_part == '') { if(isset($_POST['send'])
$_part = isset($_POST['part']) ? $_POST['part'] : ''; && $_POST['send'] == 'send')
} {
if(processForm(&$settings_data, &$_POST, array('filename' => $filename, 'action' => $action, 'page' => $page)))
if ($_part != '') { {
if ($_part == 'all') { standard_success('settingssaved', '', array('filename' => $filename, 'action' => $action, 'page' => $page));
$settings_all = true;
$settings_part = false;
} else {
$settings_all = false;
$settings_part = true;
}
$only_enabledisable = false;
} else {
$settings_all = false;
$settings_part = false;
$only_enabledisable = true;
}
// check if the session timeout is too low #815
if (isset($_POST['session_sessiontimeout']) && $_POST['session_sessiontimeout'] < 60) {
Response::standardError(lng('error.session_timeout'), lng('error.session_timeout_desc'));
}
try {
if (Form::processForm($settings_data, $_POST, [
'filename' => $filename,
'action' => $action,
'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 {
$_part = isset($_GET['part']) ? $_GET['part'] : '';
if ($_part == '') {
$_part = isset($_POST['part']) ? $_POST['part'] : '';
}
$fields = Form::buildForm($settings_data, $_part);
if ($_part == '' || $_part == 'all') {
UI::view('settings/index.html.twig', ['fields' => $fields]);
} else {
$em = Request::any('em', '');
UI::view('settings/detailpart.html.twig', ['fields' => $fields, 'em' => $em]);
} }
} }
} elseif ($page == 'phpinfo' && $userinfo['change_serversettings'] == '1') { else
ob_start(); {
phpinfo(); $fields = buildForm(&$settings_data);
$phpinfo = [ eval("echo \"" . getTemplate("settings/settings") . "\";");
'phpinfo' => [] }
]; }
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)) { elseif($page == 'rebuildconfigs'
foreach ($matches as $match) { && $userinfo['change_serversettings'] == '1')
$end = array_keys($phpinfo); {
$end = end($end); if(isset($_POST['send'])
if (strlen($match[1])) { && $_POST['send'] == 'send')
$phpinfo[$match[1]] = []; {
} elseif (isset($match[3])) { $log->logAction(ADM_ACTION, LOG_INFO, "rebuild configfiles");
$phpinfo[$end][$match[2]] = isset($match[4]) ? [ inserttask('1');
$match[3], inserttask('4');
$match[4] inserttask('5');
] : $match[3]; redirectTo('admin_index.php', array('s' => $s));
} else { }
$phpinfo[$end][] = $match[2]; else
} {
ask_yesno('admin_configs_reallyrebuild', $filename, array('page' => $page));
}
}
elseif($page == 'updatecounters'
&& $userinfo['change_serversettings'] == '1')
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$log->logAction(ADM_ACTION, LOG_INFO, "updated resource-counters");
$updatecounters = updateCounters(true);
$customers = '';
foreach($updatecounters['customers'] as $customerid => $customer)
{
eval("\$customers.=\"" . getTemplate("settings/updatecounters_row_customer") . "\";");
} }
} else {
Response::standardError(lng('error.no_phpinfo'));
}
UI::view('settings/phpinfo.html.twig', [
'phpversion' => PHP_VERSION,
'phpinfo' => $phpinfo
]);
} elseif ($page == 'rebuildconfigs' && $userinfo['change_serversettings'] == '1') {
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', '', [ $admins = '';
'filename' => 'admin_index.php' foreach($updatecounters['admins'] as $adminid => $admin)
]); {
} else { eval("\$admins.=\"" . getTemplate("settings/updatecounters_row_admin") . "\";");
HTML::askYesNo('admin_configs_reallyrebuild', $filename, [ }
'page' => $page
]); eval("echo \"" . getTemplate("settings/updatecounters") . "\";");
} }
} elseif ($page == 'updatecounters' && $userinfo['change_serversettings'] == '1') { else
if (isset($_POST['send']) && $_POST['send'] == 'send') { {
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "updated resource-counters"); ask_yesno('admin_counters_reallyupdate', $filename, array('page' => $page));
$updatecounters = User::updateCounters(true);
UI::view('user/resource-counter.html.twig', [
'counters' => $updatecounters
]);
} else {
HTML::askYesNo('admin_counters_reallyupdate', $filename, [
'page' => $page
]);
} }
} elseif ($page == 'wipecleartextmailpws' && $userinfo['change_serversettings'] == '1') { }
if (isset($_POST['send']) && $_POST['send'] == 'send') { elseif($page == 'wipecleartextmailpws'
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_WARNING, "wiped all cleartext mail passwords"); && $userinfo['change_serversettings'] == '1')
Database::query("UPDATE `" . TABLE_MAIL_USERS . "` SET `password` = '';"); {
Database::query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '0' WHERE `settinggroup` = 'system' AND `varname` = 'mailpwcleartext'"); if(isset($_POST['send'])
Response::redirectTo($filename); && $_POST['send'] == 'send')
} else { {
HTML::askYesNo('admin_cleartextmailpws_reallywipe', $filename, [ $log->logAction(ADM_ACTION, LOG_WARNING, "wiped all cleartext mail passwords");
'page' => $page $db->query("UPDATE `" . TABLE_MAIL_USERS . "` SET `password`='' ");
]); $db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value`='0' WHERE `settinggroup`='system' AND `varname`='mailpwcleartext'");
redirectTo('admin_settings.php', array('s' => $s));
} }
} elseif ($page == 'wipequotas' && $userinfo['change_serversettings'] == '1') { else
if (isset($_POST['send']) && $_POST['send'] == 'send') { {
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_WARNING, "wiped all mailquotas"); ask_yesno('admin_cleartextmailpws_reallywipe', $filename, array('page' => $page));
}
}
elseif($page == 'wipequotas'
&& $userinfo['change_serversettings'] == '1')
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$log->logAction(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_PANEL_CUSTOMERS . "` SET `email_quota_used` = '0'"); $db->query("UPDATE `" . TABLE_MAIL_USERS . "` SET `quota`='0' ");
Response::redirectTo($filename); $db->query("UPDATE " . TABLE_PANEL_CUSTOMERS . " SET `email_quota_used` = 0");
} else { redirectTo('admin_settings.php', array('s' => $s));
HTML::askYesNo('admin_quotas_reallywipe', $filename, [
'page' => $page
]);
} }
} elseif ($page == 'enforcequotas' && $userinfo['change_serversettings'] == '1') { else
if (isset($_POST['send']) && $_POST['send'] == 'send') { {
ask_yesno('admin_quotas_reallywipe', $filename, array('page' => $page));
}
}
elseif($page == 'enforcequotas'
&& $userinfo['change_serversettings'] == '1')
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
// Fetch all accounts // Fetch all accounts
$result_stmt = Database::query("SELECT `quota`, `customerid` FROM `" . TABLE_MAIL_USERS . "`");
if (Database::num_rows() > 0) { $result = $db->query("SELECT `quota`, `customerid` FROM " . TABLE_MAIL_USERS);
$upd_stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET
`email_quota_used` = `email_quota_used` + :diff
WHERE `customerid` = :customerid
");
while ($array = $result_stmt->fetch(PDO::FETCH_ASSOC)) { while($array = $db->fetch_array($result))
$difference = Settings::Get('system.mail_quota') - $array['quota']; {
Database::pexecute($upd_stmt, [ $difference = $settings['system']['mail_quota'] - $array['quota'];
'diff' => $difference, $db->query("UPDATE " . TABLE_PANEL_CUSTOMERS . " SET `email_quota_used` = `email_quota_used` + " . (int)$difference . " WHERE `customerid` = '" . $array['customerid'] . "'");
'customerid' => $customerid
]);
}
} }
// Set the new quota // Set the new quota
$upd_stmt = Database::prepare("
UPDATE `" . TABLE_MAIL_USERS . "` SET `quota` = :quota $db->query("UPDATE `" . TABLE_MAIL_USERS . "` SET `quota`='" . $settings['system']['mail_quota'] . "'");
");
Database::pexecute($upd_stmt, [
'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`");
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_WARNING, 'enforcing mailquota to all customers: ' . Settings::Get('system.mail_quota') . ' MB'); $db->query("UPDATE " . TABLE_PANEL_CUSTOMERS . " SET `email_quota` = `email_quota_used` WHERE `email_quota` < `email_quota_used`");
Response::redirectTo($filename); $log->logAction(ADM_ACTION, LOG_WARNING, 'enforcing mailquota to all customers: ' . $settings['system']['mail_quota'] . ' MB');
} else { redirectTo('admin_settings.php', array('s' => $s));
HTML::askYesNo('admin_quotas_reallyenforce', $filename, [
'page' => $page
]);
} }
} elseif ($page == 'integritycheck' && $userinfo['change_serversettings'] == '1') { else
$integrity = new IntegrityCheck(); {
if (isset($_POST['send']) && $_POST['send'] == 'send') { ask_yesno('admin_quotas_reallyenforce', $filename, array('page' => $page));
$integrity->fixAll();
} elseif (isset($_GET['action']) && $_GET['action'] == "fix") {
HTML::askYesNo('admin_integritycheck_reallyfix', $filename, [
'page' => $page
]);
} }
$integritycheck = [];
foreach ($integrity->available as $id => $check) {
$integritycheck[] = [
'displayid' => $id + 1,
'result' => $integrity->$check(),
'checkdesc' => lng('integrity_check.' . $check)
];
}
$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') {
// check for json-stuff
if (!extension_loaded('json')) {
Response::standardError('jsonextensionnotfound');
}
if (isset($_GET['action']) && $_GET['action'] == "export") {
// export
try {
$json_result = Froxlor::getLocal($userinfo)->exportSettings();
$json_export = json_decode($json_result, true)['data'];
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
header('Content-disposition: attachment; filename=Froxlor_settings-' . \Froxlor\Froxlor::VERSION . '-' . \Froxlor\Froxlor::DBVERSION . '_' . date('d.m.Y') . '.json');
header('Content-type: application/json');
echo $json_export;
exit();
} elseif (isset($_GET['action']) && $_GET['action'] == "import") {
// import
if (isset($_POST['send']) && $_POST['send'] == 'send') {
// get uploaded file
if (isset($_FILES["import_file"]["tmp_name"])) {
$imp_content = file_get_contents($_FILES["import_file"]["tmp_name"]);
try {
Froxlor::getLocal($userinfo, [
'json_str' => $imp_content
])->importSettings();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
Response::standardSuccess('settingsimported', '', [
'filename' => 'admin_settings.php'
]);
}
Response::dynamicError("Upload failed");
}
} else {
$settings_data = include_once dirname(__FILE__) . '/lib/formfields/admin/settings/formfield.settings_import.php';
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') {
$note_type = 'info';
$note_msg = lng('admin.smtptestnote');
if (isset($_POST['send']) && $_POST['send'] == 'send') {
$test_addr = isset($_POST['test_addr']) ? $_POST['test_addr'] : null;
// Initialize the mailingsystem
$testmail = new PHPMailer(true);
$testmail->CharSet = "UTF-8";
if (Settings::Get('system.mail_use_smtp')) {
$testmail->isSMTP();
$testmail->Host = Settings::Get('system.mail_smtp_host');
$testmail->SMTPAuth = Settings::Get('system.mail_smtp_auth') == '1';
$testmail->Username = Settings::Get('system.mail_smtp_user');
$testmail->Password = Settings::Get('system.mail_smtp_passwd');
if (Settings::Get('system.mail_smtp_usetls')) {
$testmail->SMTPSecure = 'tls';
} else {
$testmail->SMTPAutoTLS = false;
}
$testmail->Port = Settings::Get('system.mail_smtp_port');
}
$_mailerror = false;
if (PHPMailer::ValidateAddress(Settings::Get('panel.adminmail')) !== false) {
// set return-to address and custom sender-name, see #76
$testmail->SetFrom(Settings::Get('panel.adminmail'), Settings::Get('panel.adminmail_defname'));
if (Settings::Get('panel.adminmail_return') != '') {
$testmail->AddReplyTo(Settings::Get('panel.adminmail_return'), Settings::Get('panel.adminmail_defname'));
}
try {
$testmail->Subject = "Froxlor Test-Mail";
$mail_body = "Yay, this worked :)";
$testmail->AltBody = $mail_body;
$testmail->MsgHTML(str_replace("\n", "<br />", $mail_body));
$testmail->AddAddress($test_addr);
$testmail->Send();
} catch (\PHPMailer\PHPMailer\Exception $e) {
$note_type = 'danger';
$note_msg = $e->getMessage();
$_mailerror = true;
} catch (Exception $e) {
$note_type = 'danger';
$note_msg = $e->getMessage();
$_mailerror = true;
}
if (!$_mailerror) {
// success
$mail->ClearAddresses();
Response::standardSuccess('testmailsent', '', [
'filename' => 'admin_settings.php',
'page' => 'testmail'
]);
}
} else {
// invalid sender e-mail
$note_type = 'warning';
$note_msg = "Invalid sender e-mail address: " . Settings::Get('panel.adminmail');
}
}
$mailtest_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/settings/formfield.settings_mailtest.php';
UI::view('user/form-note.html.twig', [
'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,577 +2,380 @@
/** /**
* 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 * @version $Id$
* 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'; define('AREA', 'admin');
require __DIR__ . '/lib/init.php';
use Froxlor\Database\Database; /**
use Froxlor\FroxlorLogger; * Include our init.php, which manages Sessions, Language etc.
use Froxlor\Language; */
use Froxlor\PhpHelper;
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'); require ("./lib/init.php");
$subjectid = intval(Request::any('subjectid'));
$mailbodyid = intval(Request::any('mailbodyid'));
$available_templates = [ if(isset($_POST['subjectid']))
{
$subjectid = intval($_POST['subjectid']);
$mailbodyid = intval($_POST['mailbodyid']);
}
elseif(isset($_GET['subjectid']))
{
$subjectid = intval($_GET['subjectid']);
$mailbodyid = intval($_GET['mailbodyid']);
}
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', 'trafficninetypercent',
'new_ftpaccount_by_customer', 'new_ticket_by_customer',
'password_reset' 'new_ticket_for_customer',
]; 'new_ticket_by_staff',
'new_reply_ticket_by_customer',
// only show templates of features that are enabled #1191 'new_reply_ticket_by_staff'
if ((int)Settings::Get('system.report_enable') == 1) { );
array_push($available_templates, 'trafficmaxpercent', 'diskmaxpercent'); $file_templates = array(
}
if (Settings::Get('panel.sendalternativemail') == 1) {
array_push($available_templates, 'pop_success_alternative');
}
$file_templates = [
'index_html' 'index_html'
]; );
$languages = Language::getLanguages(); if($action == '')
{
//email templates
if ($action == '') { $log->logAction(ADM_ACTION, LOG_NOTICE, "viewed admin_templates");
// email templates
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_templates");
$templates_array = []; if($settings['panel']['sendalternativemail'] == 1)
$result_stmt = Database::prepare(" {
SELECT `id`, `language`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "` $available_templates[] = 'pop_success_alternative';
WHERE `adminid` = :adminid AND `templategroup`='mails' }
ORDER BY `language`, `varname`
");
Database::pexecute($result_stmt, [
'adminid' => $userinfo['adminid']
]);
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { $templates_array = array();
$parts = []; $result = $db->query("SELECT `id`, `language`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "` WHERE `adminid`='" . (int)$userinfo['adminid'] . "' AND `templategroup`='mails' ORDER BY `language`, `varname`");
while($row = $db->fetch_array($result))
{
$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) { {
$templates[] = [ foreach($template_defs as $action => $email)
'subjectid' => $email['subject'], {
'mailbodyid' => $email['mailbody'], $subjectid = $email['subject'];
'template' => lng('admin.templates.' . $action), $mailbodyid = $email['mailbody'];
'language' => $language $template = $lng['admin']['templates'][$action];
]; eval("\$templates.=\"" . getTemplate("templates/templates_template") . "\";");
} }
} }
$mail_actions_links = false; $add = false;
foreach ($languages as $language_file => $language_name) {
$templates_done = [];
$result_stmt = Database::prepare("
SELECT `varname` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `language`= :lang
AND `templategroup` = 'mails' AND `varname` LIKE '%_subject'
");
Database::pexecute($result_stmt, [
'adminid' => $userinfo['adminid'],
'lang' => $language_name
]);
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { while(list($language_file, $language_name) = each($languages))
{
$templates_done = array();
$result = $db->query('SELECT `varname` FROM `' . TABLE_PANEL_TEMPLATES . '` WHERE `adminid`=\'' . (int)$userinfo['adminid'] . '\' AND `language`=\'' . $db->escape($language_name) . '\' AND `templategroup`=\'mails\' AND `varname` LIKE \'%_subject\'');
while(($row = $db->fetch_array($result)) != false)
{
$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'; //filetemplates
$collection_mail = [
'data' => $templates,
'pagination' => []
];
// filetemplates $filetemplates = '';
$result_stmt = Database::prepare(" $filetemplateadd = false;
SELECT `id`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "` $result = $db->query("SELECT `id`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "` WHERE `adminid`='" . (int)$userinfo['adminid'] . "' AND `templategroup`='files'");
WHERE `adminid` = :adminid AND `templategroup`='files'");
Database::pexecute($result_stmt, [
'adminid' => $userinfo['adminid']
]);
$filetemplates = []; if($db->num_rows($result) != count($file_templates))$filetemplateadd = true;
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$filetemplates[] = [ while($row = $db->fetch_array($result))
'id' => $row['id'], {
'template' => lng('admin.templates.' . $row['varname']) eval("\$filetemplates.=\"" . getTemplate("templates/templates_filetemplate") . "\";");
];
} }
$file_actions_links = false; eval("echo \"" . getTemplate("templates/templates") . "\";");
if (Database::num_rows() != count($file_templates)) { }
$file_actions_links = [ elseif($action == 'delete'
[ && $subjectid != 0
'href' => $linker->getLink([ && $mailbodyid != 0)
'section' => 'templates', {
'page' => $page, //email templates
'action' => 'add',
'files' => 'files'
]),
'label' => lng('admin.templates.template_fileadd')
]
];
}
$filetpl_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.filetemplates.php'; $result = $db->query_first("SELECT `language`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "` WHERE `adminid`='" . (int)$userinfo['adminid'] . "' AND `id`='" . (int)$subjectid . "'");
$collection_file = [
'data' => $filetemplates,
'pagination' => []
];
if ($mail_actions_links === false) { if($result['varname'] != '')
$mail_actions_links = []; {
} if(isset($_POST['send'])
if ($file_actions_links === false) { && $_POST['send'] == 'send')
$file_actions_links = []; {
} $db->query("DELETE FROM `" . TABLE_PANEL_TEMPLATES . "` WHERE `adminid`='" . (int)$userinfo['adminid'] . "' AND (`id`='" . (int)$subjectid . "' OR `id`='" . (int)$mailbodyid . "')");
$log->logAction(ADM_ACTION, LOG_INFO, "deleted template '" . $result['language'] . ' - ' . $lng['admin']['templates'][str_replace('_subject', '', $result['varname'])] . "'");
UI::view('user/table-tpl.html.twig', [ redirectTo($filename, Array('page' => $page, 's' => $s));
'maillisting' => Listing::formatFromArray($collection_mail, $mailtpl_list_data['mailtpl_list'], 'mailtpl_list'), }
'filelisting' => Listing::formatFromArray($collection_file, $filetpl_list_data['filetpl_list'], 'filetpl_list'), else
'actions_links' => array_merge($mail_actions_links, $file_actions_links) {
]); ask_yesno('admin_template_reallydelete', $filename, array('subjectid' => $subjectid, 'mailbodyid' => $mailbodyid, 'page' => $page, 'action' => $action), $result['language'] . ' - ' . $lng['admin']['templates'][str_replace('_subject', '', $result['varname'])]);
} elseif ($action == 'delete' && $subjectid != 0 && $mailbodyid != 0) {
// email templates
$result_stmt = Database::prepare("
SELECT `language`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `id` = :id");
Database::pexecute($result_stmt, [
'adminid' => $userinfo['adminid'],
'id' => $subjectid
]);
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
if ($result['varname'] != '') {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
$del_stmt = Database::prepare("
DELETE FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid
AND (`id` = :ida OR `id` = :idb)");
Database::pexecute($del_stmt, [
'adminid' => $userinfo['adminid'],
'ida' => $subjectid,
'idb' => $mailbodyid
]);
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "deleted template '" . $result['language'] . ' - ' . lng('admin.templates.' . str_replace('_subject', '', $result['varname'])) . "'");
Response::redirectTo($filename, [
'page' => $page
]);
} else {
HTML::askYesNo('admin_template_reallydelete', $filename, [
'subjectid' => $subjectid,
'mailbodyid' => $mailbodyid,
'page' => $page,
'action' => $action
], $result['language'] . ' - ' . lng('admin.templates.' . str_replace('_subject', '', $result['varname'])));
} }
} }
} elseif ($action == 'deletef' && $id != 0) { }
// file templates elseif($action == 'delete'
$result_stmt = Database::prepare(" && $id != 0)
SELECT * FROM `" . TABLE_PANEL_TEMPLATES . "` {
WHERE `adminid` = :adminid AND `id` = :id"); //file templates
Database::pexecute($result_stmt, [
'adminid' => $userinfo['adminid'],
'id' => $id
]);
if (Database::num_rows() > 0) { $result = $db->query("SELECT * FROM `" . TABLE_PANEL_TEMPLATES . "` WHERE `adminid`='" . (int)$userinfo['adminid'] . "' AND `id`='" . (int)$id . "'");
$row = $result_stmt->fetch(PDO::FETCH_ASSOC);
if (isset($_POST['send']) && $_POST['send'] == 'send') { if($db->num_rows($result) > 0)
$del_stmt = Database::prepare(" {
DELETE FROM `" . TABLE_PANEL_TEMPLATES . "` $row = $db->fetch_array($result);
WHERE `adminid` = :adminid AND `id` = :id");
Database::pexecute($del_stmt, [ if(isset($_POST['send'])
'adminid' => $userinfo['adminid'], && $_POST['send'] == 'send')
'id' => $id {
]); $db->query("DELETE FROM `" . TABLE_PANEL_TEMPLATES . "` WHERE `adminid`=" . (int)$userinfo['adminid'] . " AND `id`=" . (int)$id . "");
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "deleted template '" . lng('admin.templates.' . $row['varname']) . "'"); $log->logAction(ADM_ACTION, LOG_INFO, "deleted template '" . $lng['admin']['templates'][$row['varname']] . "'");
Response::redirectTo($filename, [ redirectTo($filename, Array('page' => $page, 's' => $s));
'page' => $page }
]); else
} else { {
HTML::askYesNo('admin_template_reallydelete', $filename, [ ask_yesno('admin_template_reallydelete', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $lng['admin']['templates'][$row['varname']]);
'id' => $id,
'page' => $page,
'action' => $action
], lng('admin.templates.' . $row['varname']));
} }
} else {
Response::standardError('templatenotfound');
} }
} elseif ($action == 'add') { else
if (isset($_POST['prepare']) && $_POST['prepare'] == 'prepare') { {
// email templates standard_error('templatenotfound');
$language = htmlentities(Validate::validate($_POST['language'], 'language', '/^[^\r\n\0"\']+$/', 'nolanguageselect')); exit;
$template = Validate::validate($_POST['template'], 'template'); }
}
elseif($action == 'add')
{
if($settings['panel']['sendalternativemail'] == 1)
{
$available_templates[] = 'pop_success_alternative';
}
$result_stmt = Database::prepare(" if(isset($_POST['prepare'])
SELECT COUNT(*) as def FROM `" . TABLE_PANEL_TEMPLATES . "` && $_POST['prepare'] == 'prepare')
WHERE `adminid` = :adminid AND `language` = :lang {
AND `templategroup` = 'mails' AND `varname` LIKE :template //email templates
");
$result = Database::pexecute_first($result_stmt, [
'adminid' => $userinfo['adminid'],
'lang' => $language,
'template' => $template . '%'
]);
if ($result && $result['def'] > 0) {
Response::standardError('templatelanguagecombodefined');
}
// set target language $language = validate($_POST['language'], 'language');
Language::setLanguage($language); $templates = array();
$result = $db->query('SELECT `varname` FROM `' . TABLE_PANEL_TEMPLATES . '` WHERE `adminid`=\'' . (int)$userinfo['adminid'] . '\' AND `language`=\'' . $db->escape($language) . '\' AND `templategroup`=\'mails\' AND `varname` LIKE \'%_subject\'');
$subject = lng('mails.' . $template . '.subject'); while(($row = $db->fetch_array($result)) != false)
$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';
UI::view('user/form-replacers.html.twig', [
'formaction' => $linker->getLink(['section' => 'templates']),
'formdata' => $template_add_data['template_add'],
'replacers' => $template_add_data['template_replacers']
]);
} elseif (isset($_POST['send']) && $_POST['send'] == 'send' && !isset($_POST['filesend'])) {
// email templates
$language = htmlentities(Validate::validate($_POST['language'], 'language', '/^[^\r\n\0"\']+$/', 'nolanguageselect'));
$template = Validate::validate($_POST['template'], 'template');
$subject = Validate::validate($_POST['subject'], 'subject', '/^[^\r\n\0]+$/', 'nosubjectcreate');
$mailbody = Validate::validate($_POST['mailbody'], 'mailbody', '/^[^\0]+$/', 'nomailbodycreate');
$templates = [];
$result_stmt = Database::prepare("
SELECT `varname` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `language` = :lang
AND `templategroup` = 'mails' AND `varname` LIKE '%_subject'");
Database::pexecute($result_stmt, [
'adminid' => $userinfo['adminid'],
'lang' => $language
]);
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)) { $template_options = '';
Response::standardError('templatenotfound'); foreach($templates as $template)
} else { {
$ins_stmt = Database::prepare(" $template_options.= makeoption($lng['admin']['templates'][$template], $template, NULL, true);
INSERT INTO `" . TABLE_PANEL_TEMPLATES . "` SET
`adminid` = :adminid,
`language` = :lang,
`templategroup` = 'mails',
`varname` = :var,
`value` = :value");
// mail-subject
$ins_data = [
'adminid' => $userinfo['adminid'],
'lang' => $language,
'var' => $template . '_subject',
'value' => $subject
];
Database::pexecute($ins_stmt, $ins_data);
// mail-body
$ins_data = [
'adminid' => $userinfo['adminid'],
'lang' => $language,
'var' => $template . '_mailbody',
'value' => $mailbody
];
Database::pexecute($ins_stmt, $ins_data);
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "added template '" . $language . ' - ' . $template . "'");
Response::redirectTo($filename, [
'page' => $page
]);
} }
} elseif (isset($_POST['filesend']) && $_POST['filesend'] == 'filesend') {
// file templates
$template = Validate::validate($_POST['template'], 'template');
$filecontent = Validate::validate($_POST['filecontent'], 'filecontent', '/^[^\0]+$/', 'filecontentnotset');
$ins_stmt = Database::prepare(" eval("echo \"" . getTemplate("templates/templates_add_2") . "\";");
INSERT INTO `" . TABLE_PANEL_TEMPLATES . "` SET }
`adminid` = :adminid, elseif(isset($_POST['send'])
`language` = '', && $_POST['send'] == 'send')
`templategroup` = 'files', {
`varname` = :var, //email templates
`value` = :value");
$ins_data = [ $language = validate($_POST['language'], 'language', '/^[^\r\n\0"\']+$/', 'nolanguageselect');
'adminid' => $userinfo['adminid'], $template = validate($_POST['template'], 'template');
'var' => $template, $subject = validate($_POST['subject'], 'subject', '/^[^\r\n\0]+$/', 'nosubjectcreate');
'value' => $filecontent $mailbody = validate($_POST['mailbody'], 'mailbody', '/^[^\0]+$/', 'nomailbodycreate');
]; $templates = array();
Database::pexecute($ins_stmt, $ins_data); $result = $db->query('SELECT `varname` FROM `' . TABLE_PANEL_TEMPLATES . '` WHERE `adminid`=\'' . (int)$userinfo['adminid'] . '\' AND `language`=\'' . $db->escape($language) . '\' AND `templategroup`=\'mails\' AND `varname` LIKE \'%_subject\'');
while(($row = $db->fetch_array($result)) != false)
{
$templates[] = str_replace('_subject', '', $row['varname']);
}
$templates = array_diff($available_templates, $templates);
if(array_search($template, $templates) === false)
{
standard_error('templatenotfound');
}
else
{
$result = $db->query("INSERT INTO `" . TABLE_PANEL_TEMPLATES . "` (`adminid`, `language`, `templategroup`, `varname`, `value`)
VALUES ('" . (int)$userinfo['adminid'] . "', '" . $db->escape($language) . "', 'mails', '" . $db->escape($template) . "_subject','" . $db->escape($subject) . "')");
$result = $db->query("INSERT INTO `" . TABLE_PANEL_TEMPLATES . "` (`adminid`, `language`, `templategroup`, `varname`, `value`)
VALUES ('" . (int)$userinfo['adminid'] . "', '" . $db->escape($language) . "', 'mails', '" . $db->escape($template) . "_mailbody','" . $db->escape($mailbody) . "')");
$log->logAction(ADM_ACTION, LOG_INFO, "added template '" . $language . ' - ' . $template . "'");
redirectTo($filename, Array('page' => $page, 's' => $s));
}
}
elseif(isset($_POST['filesend'])
&& $_POST['filesend'] == 'filesend')
{
//file templates
$template = validate($_POST['template'], 'template');
$filecontent = validate($_POST['filecontent'], 'filecontent', '/^[^\0]+$/', 'filecontentnotset');
$db->query("INSERT INTO `" . TABLE_PANEL_TEMPLATES . "` (`adminid`, `language`, `templategroup`, `varname`, `value`)
VALUES ('" . (int)$userinfo['adminid'] . "', '', 'files', '" . $db->escape($template) . "','" . $db->escape($filecontent) . "')");
$log->logAction(ADM_ACTION, LOG_INFO, "added template '" . $template . "'");
redirectTo($filename, Array('page' => $page, 's' => $s));
}
elseif(!isset($_GET['files']))
{
//email templates
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "added template '" . $template . "'");
Response::redirectTo($filename, [
'page' => $page
]);
} elseif (!isset($_GET['files'])) {
// email templates
$add = false; $add = false;
$language_options = []; $language_options = '';
$template_options = [];
foreach ($languages as $language_file => $language_name) { while(list($language_file, $language_name) = each($languages))
$templates = []; {
$result_stmt = Database::prepare(" $templates = array();
SELECT `varname` FROM `" . TABLE_PANEL_TEMPLATES . "` $result = $db->query('SELECT `varname` FROM `' . TABLE_PANEL_TEMPLATES . '` WHERE `adminid`=\'' . (int)$userinfo['adminid'] . '\' AND `language`=\'' . $db->escape($language_name) . '\' AND `templategroup`=\'mails\' AND `varname` LIKE \'%_subject\'');
WHERE `adminid` = :adminid AND `language` = :lang
AND `templategroup` = 'mails' AND `varname` LIKE '%_subject'");
Database::pexecute($result_stmt, [
'adminid' => $userinfo['adminid'],
'lang' => $language_name
]);
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { while(($row = $db->fetch_array($result)) != false)
{
$templates[] = str_replace('_subject', '', $row['varname']); $templates[] = str_replace('_subject', '', $row['varname']);
} }
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.= makeoption($language_name, $language_file, $userinfo['language'], true);
$templates = array_diff($available_templates, $templates);
foreach ($templates as $template) {
$template_options[$template] = lng('admin.templates.' . $template);
}
} }
} }
if ($add) { if($add)
UI::view('user/form.html.twig', [ {
'formaction' => $linker->getLink(['section' => 'templates']), eval("echo \"" . getTemplate("templates/templates_add_1") . "\";");
'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 {
Response::standardError('alltemplatesdefined');
} }
} else { else
// filetemplates {
$result_stmt = Database::prepare(" standard_error('alltemplatesdefined');
SELECT `id`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "` exit;
WHERE `adminid` = :adminid AND `templategroup`='files'");
Database::pexecute($result_stmt, [
'adminid' => $userinfo['adminid']
]);
if (Database::num_rows() == count($file_templates)) {
Response::standardError('alltemplatesdefined');
} else {
$templatesdefined = [];
$free_templates = [];
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$templatesdefined[] = $row['varname'];
}
foreach (array_diff($file_templates, $templatesdefined) as $template) {
$free_templates[$template] = lng('admin.templates.' . $template);
}
$filetemplate_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/templates/formfield.filetemplate_add.php';
UI::view('user/form-replacers.html.twig', [
'formaction' => $linker->getLink(['section' => 'templates']),
'formdata' => $filetemplate_add_data['filetemplate_add'],
'replacers' => $filetemplate_add_data['filetemplate_replacers']
]);
} }
} }
} elseif ($action == 'edit' && $subjectid != 0 && $mailbodyid != 0) { else
// email templates {
$result_stmt = Database::prepare(" //filetemplates
SELECT `language`, `varname`, `value` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `id` = :subjectid");
Database::pexecute($result_stmt, [
'adminid' => $userinfo['adminid'],
'subjectid' => $subjectid
]);
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
if ($result['varname'] != '') { $result = $db->query("SELECT `id`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "` WHERE `adminid`='" . (int)$userinfo['adminid'] . "' AND `templategroup`='files'");
if (isset($_POST['send']) && $_POST['send'] == 'send') {
$subject = Validate::validate($_POST['subject'], 'subject', '/^[^\r\n\0]+$/', 'nosubjectcreate');
$mailbody = Validate::validate($_POST['mailbody'], 'mailbody', '/^[^\0]+$/', 'nomailbodycreate');
$upd_stmt = Database::prepare(" if($db->num_rows($result) == count($file_templates))
UPDATE `" . TABLE_PANEL_TEMPLATES . "` SET {
`value` = :value standard_error('alltemplatesdefined');
WHERE `adminid` = :adminid AND `id` = :id"); exit;
// subject
Database::pexecute($upd_stmt, [
'value' => $subject,
'adminid' => $userinfo['adminid'],
'id' => $subjectid
]);
// same query but mailbody
Database::pexecute($upd_stmt, [
'value' => $mailbody,
'adminid' => $userinfo['adminid'],
'id' => $mailbodyid
]);
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "edited template '" . $result['varname'] . "'");
Response::redirectTo($filename, [
'page' => $page
]);
} else {
$result = PhpHelper::htmlentitiesArray($result);
$template_name = lng('admin.templates.' . str_replace('_subject', '', $result['varname']));
$subject = $result['value'];
$result_stmt = Database::prepare("
SELECT `language`, `varname`, `value`
FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `id` = :id");
Database::pexecute($result_stmt, [
'id' => $mailbodyid
]);
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
$template = str_replace('_mailbody', '', $result['varname']);
// don't escape the already escaped language-string so save up before htmlentities()
$language = $result['language'];
$result = PhpHelper::htmlentitiesArray($result);
$mailbody = $result['value'];
$template_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/templates/formfield.template_edit.php';
UI::view('user/form-replacers.html.twig', [
'formaction' => $linker->getLink(['section' => 'templates']),
'formdata' => $template_edit_data['template_edit'],
'replacers' => $template_edit_data['template_replacers']
]);
} }
} else
} elseif ($action == 'editf' && $id != 0) { {
// file templates $templatesdefined = array();
$result_stmt = Database::prepare(" $free_templates = '';
SELECT * FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `id` = :id");
Database::pexecute($result_stmt, [
'adminid' => $userinfo['adminid'],
'id' => $id
]);
if (Database::num_rows() > 0) { while($row = $db->fetch_array($result))$templatesdefined[] = $row['varname'];
$row = $result_stmt->fetch(PDO::FETCH_ASSOC); foreach(array_diff($file_templates, $templatesdefined) as $template)
{
$free_templates.= makeoption($lng['admin']['templates'][$template], $template, '', true);
}
// filetemplates eval("echo \"" . getTemplate("templates/filetemplates_add") . "\";");
if (isset($_POST['filesend']) && $_POST['filesend'] == 'filesend') {
$filecontent = Validate::validate($_POST['filecontent'], 'filecontent', '/^[^\0]+$/', 'filecontentnotset');
$upd_stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_TEMPLATES . "` SET
`value` = :value
WHERE `adminid` = :adminid AND `id` = :id");
Database::pexecute($upd_stmt, [
'value' => $filecontent,
'adminid' => $userinfo['adminid'],
'id' => $id
]);
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "edited template '" . $row['varname'] . "'");
Response::redirectTo($filename, [
'page' => $page
]);
} else {
$row = PhpHelper::htmlentitiesArray($row);
$filetemplate_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/templates/formfield.filetemplate_edit.php';
UI::view('user/form-replacers.html.twig', [
'formaction' => $linker->getLink(['section' => 'templates']),
'formdata' => $filetemplate_edit_data['filetemplate_edit'],
'replacers' => $filetemplate_edit_data['filetemplate_replacers'],
'editid' => $id
]);
} }
} else {
Response::standardError('templatenotfound');
} }
} }
elseif($action == 'edit'
&& $subjectid != 0
&& $mailbodyid != 0)
{
//email templates
$result = $db->query_first("SELECT `language`, `varname`, `value` FROM `" . TABLE_PANEL_TEMPLATES . "` WHERE `adminid`='" . (int)$userinfo['adminid'] . "' AND `id`='" . (int)$subjectid . "'");
if($result['varname'] != '')
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$subject = validate($_POST['subject'], 'subject', '/^[^\r\n\0]+$/', 'nosubjectcreate');
$mailbody = validate($_POST['mailbody'], 'mailbody', '/^[^\0]+$/', 'nomailbodycreate');
$db->query("UPDATE `" . TABLE_PANEL_TEMPLATES . "` SET `value`='" . $db->escape($subject) . "' WHERE `adminid`='" . (int)$userinfo['adminid'] . "' AND `id`='" . (int)$subjectid . "'");
$db->query("UPDATE `" . TABLE_PANEL_TEMPLATES . "` SET `value`='" . $db->escape($mailbody) . "' WHERE `adminid`='" . (int)$userinfo['adminid'] . "' AND `id`='" . (int)$mailbodyid . "'");
$log->logAction(ADM_ACTION, LOG_INFO, "edited template '" . $result['varname'] . "'");
redirectTo($filename, Array('page' => $page, 's' => $s));
}
else
{
$result = htmlentities_array($result);
$template = $lng['admin']['templates'][str_replace('_subject', '', $result['varname'])];
$subject = $result['value'];
$result = $db->query_first("SELECT `language`, `varname`, `value` FROM `" . TABLE_PANEL_TEMPLATES . "` WHERE `id`='$mailbodyid'");
$result = htmlentities_array($result);
$mailbody = $result['value'];
eval("echo \"" . getTemplate("templates/templates_edit") . "\";");
}
}
}
elseif($action == 'edit'
&& $id != 0)
{
//file templates
$result = $db->query("SELECT * FROM `" . TABLE_PANEL_TEMPLATES . "` WHERE `adminid`='" . (int)$userinfo['adminid'] . "' AND `id`='" . (int)$id . "'");
if($db->num_rows($result) > 0)
{
$row = $db->fetch_array($result);
//filetemplates
if(isset($_POST['filesend'])
&& $_POST['filesend'] == 'filesend')
{
$filecontent = validate($_POST['filecontent'], 'filecontent', '/^[^\0]+$/', 'filecontentnotset');
$db->query("UPDATE `" . TABLE_PANEL_TEMPLATES . "` SET `value`='" . $db->escape($filecontent) . "' WHERE `adminid`='" . (int)$userinfo['adminid'] . "' AND `id`='" . (int)$id . "'");
$log->logAction(ADM_ACTION, LOG_INFO, "edited template '" . $row['varname'] . "'");
redirectTo($filename, Array('page' => $page, 's' => $s));
}
else
{
$row = htmlentities_array($row);
eval("echo \"" . getTemplate("templates/filetemplates_edit") . "\";");
}
}
else
{
standard_error('templatenotfound');
exit;
}
}
?>

813
admin_tickets.php Normal file
View File

@@ -0,0 +1,813 @@
<?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 Panel
* @version $Id$
*/
define('AREA', 'admin');
/**
* Include our init.php, which manages Sessions, Language etc.
*/
require ("./lib/init.php");
if(isset($_POST['id']))
{
$id = intval($_POST['id']);
}
elseif(isset($_GET['id']))
{
$id = intval($_GET['id']);
}
if($page == 'tickets'
&& $userinfo['customers'] != '0')
{
// Let's see how many customers we have
$countcustomers = $db->query_first("SELECT COUNT(`customerid`) as `countcustomers` FROM `" . TABLE_PANEL_CUSTOMERS . "` " . ($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = '" . (int)$userinfo['adminid'] . "' ") . "");
$countcustomers = (int)$countcustomers['countcustomers'];
if($action == '')
{
$log->logAction(ADM_ACTION, LOG_NOTICE, "viewed admin_tickets");
$fields = array(
'status' => $lng['ticket']['status'],
'priority' => $lng['ticket']['priority'],
'lastchange' => $lng['ticket']['lastchange'],
'ticket_answers' => $lng['ticket']['ticket_answers'],
'subject' => $lng['ticket']['subject'],
'lastreplier' => $lng['ticket']['lastreplier']
);
$paging = new paging($userinfo, $db, TABLE_PANEL_TICKETS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
$paging->sortfield = 'lastchange';
$paging->sortorder = 'desc';
$result = $db->query('SELECT `main`.`id`, `main`.`customerid`, (SELECT COUNT(`sub`.`id`) FROM `' . TABLE_PANEL_TICKETS . '` `sub` WHERE `sub`.`answerto` = `main`.`id`) as `ticket_answers`, `main`.`lastchange`, `main`.`subject`, `main`.`status`, `main`.`lastreplier`, `main`.`priority` FROM `' . TABLE_PANEL_TICKETS . '` as `main` WHERE `main`.`answerto` = "0" AND `archived` = "0" AND `adminid` = "' . (int)$userinfo['adminid'] . '" ' . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
$paging->setEntries($db->num_rows($result));
$sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$ctickets = array();
while($row = $db->fetch_array($result))
{
if(!isset($ctickets[$row['customerid']])
|| !is_array($ctickets[$row['customerid']]))
{
$ctickets[$row['customerid']] = array();
}
$ctickets[$row['customerid']][$row['id']] = $row;
}
if($paging->sortfield == 'customerid'
&& $paging->sortorder == 'desc')
{
krsort($ctickets);
}
else
{
ksort($ctickets);
}
$i = 0;
$count = 0;
$tickets_count = 0;
$tickets = '';
foreach($ctickets as $cid => $ticketrows)
{
$_cid = 0;
foreach($ticketrows as $row)
{
if($paging->checkDisplay($i))
{
$row = htmlentities_array($row);
$row['lastchange'] = date("d.m.y H:i", $row['lastchange']);
if($_cid != $row['customerid'])
{
$cid = $row['customerid'];
$usr = $db->query_first('SELECT `firstname`, `name`, `loginname` FROM `' . TABLE_PANEL_CUSTOMERS . '`
WHERE `customerid` = "' . (int)$cid . '"');
if(isset($usr['loginname'])) {
$customer = $usr['firstname'] . " " . $usr['name'] . " (" . $usr['loginname'] . ")";
} else {
$customer = $lng['ticket']['nonexistingcustomer'];
}
eval("\$tickets.=\"" . getTemplate("ticket/tickets_customer") . "\";");
}
$tickets_count++;
if($row['status'] >= 0
&& $row['status'] <= 2)
{
$reopen = 0;
}
else
{
$reopen = 1;
}
$row['status'] = ticket::getStatusText($lng, $row['status']);
$row['priority'] = ticket::getPriorityText($lng, $row['priority']);
if($row['lastreplier'] == '1')
{
$row['lastreplier'] = $lng['ticket']['staff'];
$cananswer = 0;
}
else
{
$row['lastreplier'] = $lng['ticket']['customer'];
$cananswer = 1;
}
if(strlen($row['subject']) > 20)
{
$row['subject'] = substr($row['subject'], 0, 17) . '...';
}
eval("\$tickets.=\"" . getTemplate("ticket/tickets_tickets") . "\";");
$count++;
$_cid = $row['customerid'];
}
}
$i++;
}
eval("echo \"" . getTemplate("ticket/tickets") . "\";");
}
elseif($action == 'new')
{
if($userinfo['tickets_used'] < $userinfo['tickets']
|| $userinfo['tickets'] == '-1')
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$newticket = ticket::getInstanceOf($userinfo, $db, $settings, -1);
$newticket->Set('subject', validate($_POST['subject'], 'subject'), true, false);
$newticket->Set('priority', validate($_POST['priority'], 'priority'), true, false);
$newticket->Set('category', validate($_POST['category'], 'category'), true, false);
$newticket->Set('customer', validate($_POST['customer'], 'customer'), true, false);
$newticket->Set('message', validate(str_replace("\r\n", "\n", $_POST['message']), 'message', '/^[^\0]*$/'), true, false);
if($newticket->Get('subject') == null)
{
standard_error(array('stringisempty', 'mysubject'));
}
elseif($newticket->Get('message') == null)
{
standard_error(array('stringisempty', 'mymessage'));
}
else
{
$now = time();
$newticket->Set('admin', $userinfo['adminid'], true, true);
$newticket->Set('dt', $now, true, true);
$newticket->Set('lastchange', $now, true, true);
$newticket->Set('ip', $_SERVER['REMOTE_ADDR'], true, true);
$newticket->Set('status', '0', true, true);
$newticket->Set('lastreplier', '1', true, true);
$newticket->Set('by', '1', true, true);
$newticket->Insert();
$newticket->sendMail((int)$newticket->Get('customer'), 'new_ticket_by_staff_subject', $lng['mails']['new_ticket_by_staff']['subject'], 'new_ticket_by_staff_mailbody', $lng['mails']['new_ticket_by_staff']['mailbody']);
$log->logAction(ADM_ACTION, LOG_NOTICE, "opened a new ticket for customer #" . $newticket->Get('customer') . " - '" . $newticket->Get('subject') . "'");
redirectTo($filename, Array('page' => $page, 's' => $s));
}
}
else
{
$categories = '';
$result = $db->query_first('SELECT `id`, `name` FROM `' . TABLE_PANEL_TICKET_CATS . '` WHERE `adminid` = "' . $userinfo['adminid'] . '" ORDER BY `name` ASC');
if(isset($result['name'])
&& $result['name'] != '')
{
$result2 = $db->query('SELECT `id`, `name` FROM `' . TABLE_PANEL_TICKET_CATS . '` WHERE `adminid` = "' . $userinfo['adminid'] . '" ORDER BY `name` ASC');
while($row = $db->fetch_array($result2))
{
$categories.= makeoption($row['name'], $row['id']);
}
}
else
{
$categories = makeoption($lng['ticket']['no_cat'], '0');
}
$customers = '';
$result_customers = $db->query("SELECT `customerid`, `loginname`, `name`, `firstname`, `company` FROM `" . TABLE_PANEL_CUSTOMERS . "` " . ($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = '" . (int)$userinfo['adminid'] . "' ") . " ORDER BY `name` ASC");
while($row_customer = $db->fetch_array($result_customers))
{
if($row_customer['company'] == '')
{
$customers.= makeoption($row_customer['name'] . ', ' . $row_customer['firstname'] . ' (' . $row_customer['loginname'] . ')', $row_customer['customerid']);
}
else
{
if($row_customer['name'] != ''
&& $row_customer['firstname'] != '')
{
$customers.= makeoption($row_customer['name'] . ', ' . $row_customer['firstname'] . ' | ' . $row_customer['company'] . ' (' . $row_customer['loginname'] . ')', $row_customer['customerid']);
}
else
{
$customers.= makeoption($row_customer['company'] . ' (' . $row_customer['loginname'] . ')', $row_customer['customerid']);
}
}
}
$priorities = makeoption($lng['ticket']['unf_high'], '1');
$priorities.= makeoption($lng['ticket']['unf_normal'], '2');
$priorities.= makeoption($lng['ticket']['unf_low'], '3');
eval("echo \"" . getTemplate("ticket/tickets_new") . "\";");
}
}
else
{
standard_error('nomoreticketsavailable');
}
}
elseif($action == 'answer'
&& $id != 0)
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$replyticket = ticket::getInstanceOf($userinfo, $db, $settings, -1);
$replyticket->Set('subject', validate($_POST['subject'], 'subject'), true, false);
$replyticket->Set('priority', validate($_POST['priority'], 'priority'), true, false);
$replyticket->Set('message', validate(str_replace("\r\n", "\n", $_POST['message']), 'message', '/^[^\0]*$/'), true, false);
if($replyticket->Get('message') == null)
{
standard_error(array('stringisempty', 'mymessage'));
}
else
{
$now = time();
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
$replyticket->Set('customerid', $mainticket->Get('customer'), true, true);
$replyticket->Set('lastchange', $now, true, true);
$replyticket->Set('ip', $_SERVER['REMOTE_ADDR'], true, true);
$replyticket->Set('status', '1', true, true);
$replyticket->Set('answerto', (int)$id, true, false);
$replyticket->Set('by', '1', true, true);
$replyticket->Insert();
// Update priority if changed
if($replyticket->Get('priority') != $mainticket->Get('priority'))
{
$mainticket->Set('priority', $replyticket->Get('priority'), true);
}
$mainticket->Set('lastchange', $now);
$mainticket->Set('lastreplier', '1');
$mainticket->Set('status', '2');
$mainticket->Update();
$mainticket->sendMail((int)$mainticket->Get('customer'), 'new_reply_ticket_by_staff_subject', $lng['mails']['new_reply_ticket_by_staff']['subject'], 'new_reply_ticket_by_staff_mailbody', $lng['mails']['new_reply_ticket_by_staff']['mailbody']);
$log->logAction(ADM_ACTION, LOG_NOTICE, "answered ticket '" . $mainticket->Get('subject') . "'");
redirectTo($filename, Array('page' => $page, 's' => $s));
}
}
else
{
$ticket_replies = '';
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
$dt = date("d.m.Y H:i\h", $mainticket->Get('dt'));
$status = ticket::getStatusText($lng, $mainticket->Get('status'));
if($mainticket->Get('status') >= 0
&& $mainticket->Get('status') <= 2)
{
$isclosed = 0;
}
else
{
$isclosed = 1;
}
if($mainticket->Get('by') == '1')
{
$by = $lng['ticket']['staff'];
}
else
{
$by = $lng['ticket']['customer'];
}
$subject = $mainticket->Get('subject');
$message = $mainticket->Get('message');
eval("\$ticket_replies.=\"" . getTemplate("ticket/tickets_tickets_main") . "\";");
$result = $db->query('SELECT `name` FROM `' . TABLE_PANEL_TICKET_CATS . '`
WHERE `id`="' . (int)$mainticket->Get('category') . '"');
$row = $db->fetch_array($result);
$andere = $db->query('SELECT * FROM `' . TABLE_PANEL_TICKETS . '` WHERE `answerto`="' . (int)$id . '" ORDER BY `lastchange` ASC');
while($row2 = $db->fetch_array($andere))
{
$subticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$row2['id']);
$lastchange = date("d.m.Y H:i\h", $subticket->Get('lastchange'));
if($subticket->Get('by') == '1')
{
$by = $lng['ticket']['staff'];
}
else
{
$by = $lng['ticket']['customer'];
}
$subject = $subticket->Get('subject');
$message = $subticket->Get('message');
eval("\$ticket_replies.=\"" . getTemplate("ticket/tickets_tickets_list") . "\";");
}
$priorities = makeoption($lng['ticket']['high'], '1', $mainticket->Get('priority'), true, true);
$priorities.= makeoption($lng['ticket']['normal'], '2', $mainticket->Get('priority'), true, true);
$priorities.= makeoption($lng['ticket']['low'], '3', $mainticket->Get('priority'), true, true);
$subject = $mainticket->Get('subject');
$ticket_replies_count = $db->num_rows($andere) + 1;
// don't forget the main-ticket!
eval("echo \"" . getTemplate("ticket/tickets_reply") . "\";");
}
}
elseif($action == 'close'
&& $id != 0)
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$now = time();
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
$mainticket->Set('lastchange', $now, true, true);
$mainticket->Set('lastreplier', '1', true, true);
$mainticket->Set('status', '3', true, true);
$mainticket->Update();
$log->logAction(ADM_ACTION, LOG_NOTICE, "closed ticket '" . $mainticket->Get('subject') . "'");
redirectTo($filename, Array('page' => $page, 's' => $s));
}
else
{
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
ask_yesno('ticket_reallyclose', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $mainticket->Get('subject'));
}
}
elseif($action == 'reopen'
&& $id != 0)
{
$now = time();
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
$mainticket->Set('lastchange', $now, true, true);
$mainticket->Set('lastreplier', '1', true, true);
$mainticket->Set('status', '0', true, true);
$mainticket->Update();
$log->logAction(ADM_ACTION, LOG_NOTICE, "reopened ticket '" . $mainticket->Get('subject') . "'");
redirectTo($filename, Array('page' => $page, 's' => $s));
}
elseif($action == 'archive'
&& $id != 0)
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$now = time();
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
$mainticket->Set('lastchange', $now, true, true);
$mainticket->Set('lastreplier', '1', true, true);
$mainticket->Set('status', '3', true, true);
$mainticket->Update();
$mainticket->Archive();
$log->logAction(ADM_ACTION, LOG_NOTICE, "archived ticket '" . $mainticket->Get('subject') . "'");
redirectTo($filename, Array('page' => $page, 's' => $s));
}
else
{
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
ask_yesno('ticket_reallyarchive', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $mainticket->Get('subject'));
}
}
elseif($action == 'delete'
&& $id != 0)
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
$log->logAction(ADM_ACTION, LOG_INFO, "deleted ticket '" . $mainticket->Get('subject') . "'");
$mainticket->Delete();
redirectTo($filename, Array('page' => $page, 's' => $s));
}
else
{
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
ask_yesno('ticket_reallydelete', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $mainticket->Get('subject'));
}
}
}
elseif($page == 'categories'
&& $userinfo['customers'] != '0')
{
if($action == '')
{
$log->logAction(ADM_ACTION, LOG_NOTICE, "viewed admin_tickets::categories");
$fields = array(
'name' => $lng['ticket']['category']
);
$paging = new paging($userinfo, $db, TABLE_PANEL_TICKET_CATS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
$result = $db->query("SELECT `main`.`id`, `main`.`name`, (
SELECT COUNT(`sub`.`id`) FROM `" . TABLE_PANEL_TICKETS . "` `sub`
WHERE `sub`.`category` = `main`.`id`
AND `sub`.`answerto` = '0' AND `sub`.`adminid` = '" . $userinfo['adminid'] . "')
as `ticketcount`, (
SELECT COUNT(`sub2`.`id`) FROM `" . TABLE_PANEL_TICKETS . "` `sub2`
WHERE `sub2`.`category` = `main`.`id`
AND `sub2`.`answerto` = '0'
AND (`sub2`.`status` = '0' OR `sub2`.`status` = '1' OR `sub2`.`status` = '2')
AND `sub2`.`adminid` = '" . $userinfo['adminid'] . "'
) as `ticketcountnotclosed`
FROM `" . TABLE_PANEL_TICKET_CATS . "` `main` WHERE `main`.`adminid` = '" . (int)$userinfo['adminid'] . "' " . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
$paging->setEntries($db->num_rows($result));
$sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$i = 0;
$count = 0;
$ticketcategories = '';
$categories_count = $db->num_rows($result);
while($row = $db->fetch_array($result))
{
if($paging->checkDisplay($i))
{
$row = htmlentities_array($row);
$closedtickets_count = ($row['ticketcount'] - $row['ticketcountnotclosed']);
eval("\$ticketcategories.=\"" . getTemplate("ticket/tickets_categories") . "\";");
$count++;
}
$i++;
}
eval("echo \"" . getTemplate("ticket/categories") . "\";");
}
elseif($action == 'addcategory')
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$category = validate($_POST['category'], 'category');
if($category == '')
{
standard_error(array('stringisempty', 'mycategory'));
}
else
{
ticket::addCategory($db, $category, $userinfo['adminid']);
$log->logAction(ADM_ACTION, LOG_INFO, "added ticket-category '" . $category . "'");
redirectTo($filename, Array('page' => $page, 's' => $s));
}
}
else
{
eval("echo \"" . getTemplate("ticket/tickets_newcategory") . "\";");
}
}
elseif($action == 'editcategory'
&& $id != 0)
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$category = validate($_POST['category'], 'category');
if($category == '')
{
standard_error(array('stringisempty', 'mycategory'));
}
else
{
ticket::editCategory($db, $category, $id);
$log->logAction(ADM_ACTION, LOG_INFO, "edited ticket-category '" . $category . "'");
redirectTo($filename, Array('page' => $page, 's' => $s));
}
}
else
{
$row = $db->query_first('SELECT * FROM `' . TABLE_PANEL_TICKET_CATS . '` WHERE `id` = "' . (int)$id . '"');
eval("echo \"" . getTemplate("ticket/tickets_editcategory") . "\";");
}
}
elseif($action == 'deletecategory'
&& $id != 0)
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
if(ticket::deleteCategory($db, $id) == false)
{
standard_error('categoryhastickets');
}
$log->logAction(ADM_ACTION, LOG_INFO, "deleted ticket-category #" . $id);
redirectTo($filename, Array('page' => $page, 's' => $s));
}
else
{
$name = ticket::getCategoryName($db, $id);
ask_yesno('ticket_reallydeletecat', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $name);
}
}
}
elseif($page == 'archive'
&& $userinfo['customers'] != '0')
{
if($action == '')
{
$log->logAction(ADM_ACTION, LOG_NOTICE, "viewed admin_tickets::archive");
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$priority = array();
$categories = array();
$subject = validate($_POST['subject'], 'subject');
$priority[0] = isset($_POST['priority1']) ? $_POST['priority1'] : '';
$priority[1] = isset($_POST['priority2']) ? $_POST['priority2'] : '';
$priority[2] = isset($_POST['priority3']) ? $_POST['priority3'] : '';
$fromdate = validate($_POST['fromdate'], 'fromdate');
$todate = validate($_POST['todate'], 'todate');
$message = validate($_POST['message'], 'message');
$customer = validate($_POST['customer'], 'customer');
$cat = $db->query_first('SELECT COUNT(`id`) as `ccount` FROM `' . TABLE_PANEL_TICKET_CATS . '`');
for ($x = 0;$x < $cat['ccount'];$x++)
{
$categories[$x] = isset($_POST['category' . $x]) ? $_POST['category' . $x] : '';
}
$query = ticket::getArchiveSearchStatement($subject, $priority, $fromdate, $todate, $message, $customer, $userinfo['adminid'], $categories);
$fields = array(
'lastchange' => $lng['ticket']['lastchange'],
'ticket_answers' => $lng['ticket']['ticket_answers'],
'subject' => $lng['ticket']['subject'],
'lastreplier' => $lng['ticket']['lastreplier'],
'priority' => $lng['ticket']['priority']
);
$paging = new paging($userinfo, $db, TABLE_PANEL_TICKETS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
$result = $db->query($query . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
$sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$ctickets = array();
while($row = $db->fetch_array($result))
{
if(!isset($ctickets[$row['customerid']])
|| !is_array($ctickets[$row['customerid']]))
{
$ctickets[$row['customerid']] = array();
}
$ctickets[$row['customerid']][$row['id']] = $row;
}
if($paging->sortfield == 'customerid'
&& $paging->sortorder == 'desc')
{
krsort($ctickets);
}
else
{
ksort($ctickets);
}
$i = 0;
$count = 0;
$tickets_count = 0;
$tickets = '';
foreach($ctickets as $cid => $ticketrows)
{
if($paging->sortfield == 'lastchange'
&& $paging->sortorder == 'desc')
{
krsort($ticketrows);
}
else
{
ksort($ticketrows);
}
$_cid = 0;
foreach($ticketrows as $ticket)
{
if($paging->checkDisplay($i))
{
$ticket = htmlentities_array($ticket);
$ticket['lastchange'] = date("d.m.y H:i", $ticket['lastchange']);
if($_cid != $ticket['customerid'])
{
$cid = $ticket['customerid'];
$usr = $db->query_first('SELECT `firstname`, `name`, `loginname` FROM `' . TABLE_PANEL_CUSTOMERS . '`
WHERE `customerid` = "' . (int)$cid . '"');
if(isset($usr['loginname'])) {
$customer = $usr['firstname'] . " " . $usr['name'] . " (" . $usr['loginname'] . ")";
} else {
$customer = $lng['ticket']['nonexistingcustomer'];
}
eval("\$tickets.=\"" . getTemplate("ticket/tickets_customer") . "\";");
}
$tickets_count++;
$ticket['priority'] = ticket::getPriorityText($lng, $ticket['priority']);
if($ticket['lastreplier'] == '1')
{
$ticket['lastreplier'] = $lng['ticket']['staff'];
}
else
{
$ticket['lastreplier'] = $lng['ticket']['customer'];
}
if(strlen($ticket['subject']) > 20)
{
$ticket['subject'] = substr($ticket['subject'], 0, 17) . '...';
}
eval("\$tickets.=\"" . getTemplate("ticket/archived_tickets") . "\";");
$count++;
$_cid = $ticket['customerid'];
}
}
$i++;
}
eval("echo \"" . getTemplate("ticket/archivesearch") . "\";");
}
else
{
$archived = array();
$archived = ticket::getLastArchived($db, 6, $userinfo['adminid']);
$tickets = '';
if($archived !== false)
{
foreach($archived as $id => $ticket)
{
$ticket['lastchange'] = date("d.m.y H:i", $ticket['lastchange']);
$ticket['priority'] = ticket::getPriorityText($lng, $ticket['priority']);
if($ticket['lastreplier'] == '1')
{
$ticket['lastreplier'] = $lng['ticket']['staff'];
}
else
{
$ticket['lastreplier'] = $lng['ticket']['customer'];
}
if(strlen($ticket['subject']) > 20)
{
$ticket['subject'] = substr($ticket['subject'], 0, 17) . '...';
}
eval("\$tickets.=\"" . getTemplate("ticket/archived_tickets") . "\";");
}
}
$priorities_options = makecheckbox('priority1', $lng['ticket']['unf_high'], '1');
$priorities_options.= makecheckbox('priority2', $lng['ticket']['unf_normal'], '2');
$priorities_options.= makecheckbox('priority3', $lng['ticket']['unf_low'], '3');
$category_options = '';
$ccount = 0;
$result = $db->query('SELECT * FROM `' . TABLE_PANEL_TICKET_CATS . '` ORDER BY `name` ASC');
while($row = $db->fetch_array($result))
{
$category_options.= makecheckbox('category' . $ccount, $row['name'], $row['id'], true);
$ccount++;
}
$customers = makeoption($lng['ticket']['nocustomer'], '-1', '-1');
$result = $db->query_first('SELECT `customerid` FROM `' . TABLE_PANEL_CUSTOMERS . '` ' . ($userinfo['customers_see_all'] ? '' : ' WHERE `adminid` = "' . (int)$userinfo['adminid'] . '" ') . 'ORDER BY `name` ASC');
if(isset($result['customerid'])
&& $result['customerid'] != '')
{
$result2 = $db->query('SELECT `customerid`, `loginname`, `firstname`, `name`
FROM `' . TABLE_PANEL_CUSTOMERS . '` ' . ($userinfo['customers_see_all'] ? '' : ' WHERE `adminid` = "' . (int)$userinfo['adminid'] . '" ') . ' ORDER BY `name` ASC');
while($row = $db->fetch_array($result2))
{
$customers.= makeoption($row['name'] . ', ' . $row['firstname'] . ' (' . $row['loginname'] . ')', $row['customerid']);
}
}
eval("echo \"" . getTemplate("ticket/archive") . "\";");
}
}
elseif($action == 'view'
&& $id != 0)
{
$log->logAction(ADM_ACTION, LOG_NOTICE, "viewed archived-ticket #" . $id);
$ticket_replies = '';
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
$lastchange = date("d.m.Y H:i\h", $mainticket->Get('lastchange'));
$status = ticket::getStatusText($lng, $mainticket->Get('status'));
$isclosed = 1;
if($mainticket->Get('by') == '1')
{
$by = $lng['ticket']['staff'];
}
else
{
$by = $lng['ticket']['customer'];
}
$subject = $mainticket->Get('subject');
$message = $mainticket->Get('message');
eval("\$ticket_replies.=\"" . getTemplate("ticket/tickets_tickets_main") . "\";");
$result = $db->query('SELECT `name` FROM `' . TABLE_PANEL_TICKET_CATS . '`
WHERE `id`="' . (int)$mainticket->Get('category') . '"');
$row = $db->fetch_array($result);
$andere = $db->query('SELECT * FROM `' . TABLE_PANEL_TICKETS . '` WHERE `answerto`="' . (int)$id . '"');
while($row2 = $db->fetch_array($andere))
{
$subticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$row2['id']);
$lastchange = date("d.m.Y H:i\h", $subticket->Get('lastchange'));
if($subticket->Get('by') == '1')
{
$by = $lng['ticket']['staff'];
}
else
{
$by = $lng['ticket']['customer'];
}
$subject = $subticket->Get('subject');
$message = $subticket->Get('message');
eval("\$ticket_replies.=\"" . getTemplate("ticket/tickets_tickets_list") . "\";");
}
$priorities = makeoption($lng['ticket']['high'], '1', $mainticket->Get('priority'), true, true);
$priorities.= makeoption($lng['ticket']['normal'], '2', $mainticket->Get('priority'), true, true);
$priorities.= makeoption($lng['ticket']['low'], '3', $mainticket->Get('priority'), true, true);
$subject = $mainticket->Get('subject');
$ticket_replies_count = $db->num_rows($andere) + 1;
// don't forget the main-ticket!
eval("echo \"" . getTemplate("ticket/tickets_view") . "\";");
}
elseif($action == 'delete'
&& $id != 0)
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
$log->logAction(ADM_ACTION, LOG_INFO, "deleted archived ticket '" . $mainticket->Get('subject') . "'");
$mainticket->Delete();
redirectTo($filename, Array('page' => $page, 's' => $s));
}
else
{
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
ask_yesno('ticket_reallydelete', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $mainticket->Get('subject'));
}
}
}
?>

View File

@@ -1,48 +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\Traffic\Traffic;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
use Froxlor\UI\Response;
$range = Request::any('range', 'currentmonth');
if ($page == 'overview' || $page == 'customers') {
try {
$context = Traffic::getCustomerStats($userinfo, $range);
} catch (Exception $e) {
if ($e->getCode() === 405) {
Response::dynamicError(lng('traffic.nocustomers'));
}
Response::dynamicError($e->getMessage());
}
// pass metrics to the view
UI::view('user/traffic.html.twig', $context);
}

View File

@@ -4,113 +4,64 @@
* 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
* * @version $Id$
* 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'; define('AREA', 'admin');
require __DIR__ . '/lib/init.php'; require ("./lib/init.php");
use Froxlor\Cron\TaskId; if($page == 'overview')
use Froxlor\Froxlor; {
use Froxlor\FroxlorLogger; $log->logAction(ADM_ACTION, LOG_NOTICE, "viewed admin_updates");
use Froxlor\Install\Preconfig;
use Froxlor\Install\Update; if(hasUpdates($version))
use Froxlor\Settings; {
use Froxlor\System\Cronjob; if(isset($_POST['send'])
use Froxlor\UI\Panel\UI; && $_POST['send'] == 'send')
use Froxlor\UI\Response; {
use Froxlor\User;
eval("echo \"" . getTemplate("update/update_start") . "\";");
if ($page == 'overview') {
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_updates"); include_once('./install/updatesql.php');
if (!Froxlor::isFroxlor()) { $redirect_url = 'admin_index.php';
throw new Exception('SysCP/customized upgrades are not supported'); eval("echo \"" . getTemplate("update/update_end") . "\";");
updateCounters();
inserttask('1');
@chmod('./lib/userdata.inc.php', 0440);
}
else
{
$current_version = $settings['panel']['version'];
$new_version = $version;
$ui_text = $lng['update']['update_information'];
$ui_text = str_replace('%curversion', $current_version, $ui_text);
$ui_text = str_replace('%newversion', $new_version, $ui_text);
$update_information = $ui_text;
eval("echo \"" . getTemplate("update/index") . "\";");
}
} }
else
{
/*
* @TODO version-webcheck check here
*/
if (Froxlor::hasDbUpdates() || Froxlor::hasUpdates()) { $success_message = $lng['update']['noupdatesavail'];
$successful_update = false; $redirect_url = 'admin_index.php';
$message = ''; eval("echo \"" . getTemplate("update/noupdatesavail") . "\";");
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'])) {
include_once Froxlor::getInstallDir() . 'install/updatesql.php';
User::updateCounters();
Cronjob::inserttask(TaskId::REBUILD_VHOST);
@chmod(Froxlor::getInstallDir() . '/lib/userdata.inc.php', 0400);
UI::view('install/update.html.twig', [
'checks' => Update::getUpdateTasks()
]);
exit;
} else {
$message = '<br><br><strong>You have to agree that you have read the update notifications.</strong>';
}
}
$current_version = Settings::Get('panel.version');
$current_db_version = Settings::Get('panel.db_version');
if (empty($current_db_version)) {
$current_db_version = "0";
}
$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 {
Response::standardSuccess('update.noupdatesavail', Settings::Get('system.update_channel') == 'testing' ? lng('serversettings.uc_testing') . ' ' : '');
} }
} }
?>

44
api.php
View File

@@ -1,44 +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
*/
use Froxlor\Api\Api;
use Froxlor\Api\Response;
require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/lib/functions.php';
require __DIR__ . '/lib/tables.inc.php';
// set error-handler
@set_error_handler([
'\\Froxlor\\Api\\Api',
'phpErrHandler'
]);
// Return response
try {
echo (new Api)->formatMiddleware(@file_get_contents('php://input'))->handle();
} catch (Exception $e) {
echo Response::jsonErrorResponse($e->getMessage(), $e->getCode());
}

View File

@@ -1,186 +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\Database\Database;
use Froxlor\FroxlorLogger;
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 has no permission for API usage
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
// and therefore does not need to require lib/init.php
$del_stmt = Database::prepare("DELETE FROM `" . TABLE_API_KEYS . "` WHERE id = :id");
$id = (int)Request::any('id');
// do the delete and then just show a success-message and the apikeys list again
if ($action == 'delete' && $id > 0) {
HTML::askYesNo('apikey_reallydelete', $filename, [
'id' => $id,
'page' => $page,
'action' => 'deletesure'
], '', [
'section' => 'index',
'page' => $page
]);
} elseif (isset($_POST['send']) && $_POST['send'] == 'send' && $action == 'deletesure' && $id > 0) {
$chk = (AREA == 'admin' && $userinfo['customers_see_all'] == '1') ? true : false;
if (AREA == 'customer') {
$chk_stmt = Database::prepare("
SELECT c.customerid FROM `" . TABLE_PANEL_CUSTOMERS . "` c
LEFT JOIN `" . TABLE_API_KEYS . "` ak ON ak.customerid = c.customerid
WHERE ak.`id` = :id AND c.`customerid` = :cid
");
$chk = Database::pexecute_first($chk_stmt, [
'id' => $id,
'cid' => $userinfo['customerid']
]);
} elseif (AREA == 'admin' && $userinfo['customers_see_all'] == '0') {
$chk_stmt = Database::prepare("
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
");
$chk = Database::pexecute_first($chk_stmt, [
'id' => $id,
'aid' => $userinfo['adminid']
]);
}
if ($chk !== false) {
Database::pexecute($del_stmt, [
'id' => $id
]);
Response::standardSuccess('apikeys.apikey_removed', $id, [
'filename' => $filename,
'page' => $page
]);
}
} elseif ($action == 'add') {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
$ins_stmt = Database::prepare("
INSERT INTO `" . TABLE_API_KEYS . "` SET
`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
if (AREA == 'admin') {
$cid = 0;
} elseif (AREA == 'customer') {
$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, [
'id' => $id,
'page' => $page,
'action' => $action
], '', [
'section' => 'index',
'page' => $page
]);
exit;
}
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed api::api_keys");
// select all my (accessible) api-keys
$keys_stmt_query = "SELECT ak.*, c.loginname, a.loginname as adminname
FROM `" . TABLE_API_KEYS . "` ak
LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` c ON `c`.`customerid` = `ak`.`customerid`
LEFT JOIN `" . TABLE_PANEL_ADMINS . "` a ON `a`.`adminid` = `ak`.`adminid`
WHERE ";
$qry_params = [];
if (AREA == 'admin' && $userinfo['customers_see_all'] == '0') {
// admin with only customer-specific permissions
$keys_stmt_query .= "ak.adminid = :adminid ";
$qry_params['adminid'] = $userinfo['adminid'];
$fields = [
'a.loginname' => lng('login.username')
];
} elseif (AREA == 'customer') {
// customer-area
$keys_stmt_query .= "ak.customerid = :cid ";
$qry_params['cid'] = $userinfo['customerid'];
$fields = [
'c.loginname' => lng('login.username')
];
} else {
// admin who can see all customers / reseller / admins
$keys_stmt_query .= "1 ";
$fields = [
'a.loginname' => lng('login.username')
];
}
//$keys_stmt_query .= $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit();
$keys_stmt = Database::prepare($keys_stmt_query);
Database::pexecute($keys_stmt, $qry_params);
$all_keys = $keys_stmt->fetchAll(PDO::FETCH_ASSOC);
$apikeys_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/tablelisting.apikeys.php';
$collection = [
'data' => $all_keys,
'pagination' => []
];
$tpl = 'user/table.html.twig';
UI::view($tpl, [
'listing' => Listing::formatFromArray($collection, $apikeys_list_data['apikeys_list'], 'apikeys_list'),
'actions_links' => (int)$userinfo['api_allowed'] == 1 ? [
[
'href' => $linker->getLink(['section' => 'index', 'page' => $page, 'action' => 'add']),
'label' => lng('apikeys.key_add')
]
] : null,
]);

View File

@@ -1,62 +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\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->run();

278
build.xml
View File

@@ -1,278 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="froxlor" default="build">
<!-- Use this when the tools are managed by Composer in ${basedir}/vendor/bin -->
<property name="pdepend" value="${basedir}/vendor/bin/pdepend" />
<property name="phpcpd" value="${basedir}/vendor/bin/phpcpd" />
<property name="phpcs" value="${basedir}/vendor/bin/phpcs" />
<property name="phploc" value="${basedir}/vendor/bin/phploc" />
<property name="phpmd" value="${basedir}/vendor/bin/phpmd" />
<property name="phpunit" value="${basedir}/vendor/bin/phpunit" />
<target name="full-build"
depends="prepare,composer,static-analysis,phpunit,-check-failure"
description="Performs static analysis, runs the tests, and generates project documentation" />
<target name="full-build-parallel"
depends="prepare,composer,static-analysis-parallel,phpunit,-check-failure"
description="Performs static analysis (executing the tools in parallel), runs the tests, and generates project documentation" />
<target name="quick-build"
depends="prepare,composer,lint,phpunit-no-coverage,-check-failure"
description="Performs a lint check and runs the tests (without generating code coverage reports)" />
<target name="static-analysis"
depends="composer,lint,phploc-ci,pdepend,phpmd-ci,phpcs-ci,phpcompat-ci,phpcpd-ci"
description="Performs static analysis" />
<!-- Adjust the threadCount attribute's value to the number of CPUs -->
<target name="static-analysis-parallel"
description="Performs static analysis (executing the tools in parallel)">
<parallel threadCount="2">
<sequential>
<antcall target="pdepend" />
<antcall target="phpmd-ci" />
</sequential>
<antcall target="lint" />
<antcall target="phpcpd-ci" />
<antcall target="phpcs-ci" />
<antcall target="phpcompat-ci" />
<antcall target="phploc-ci" />
</parallel>
</target>
<target name="clean" unless="clean.done"
description="Cleanup build artifacts">
<delete dir="${basedir}/build/api" />
<delete dir="${basedir}/build/coverage" />
<delete dir="${basedir}/build/logs" />
<delete dir="${basedir}/build/pdepend" />
<property name="clean.done" value="true" />
</target>
<target name="prepare" unless="prepare.done" depends="clean"
description="Prepare for build">
<mkdir dir="${basedir}/build/api" />
<mkdir dir="${basedir}/build/coverage" />
<mkdir dir="${basedir}/build/logs" />
<mkdir dir="${basedir}/build/pdepend" />
<property name="prepare.done" value="true" />
</target>
<target name="composer"
description="Installing composer dependencies" depends="prepare">
<exec executable="composer" failonerror="true">
<arg value="install" />
<arg value="--prefer-dist" />
<arg value="--no-progress" />
</exec>
</target>
<target name="lint" unless="lint.done"
description="Perform syntax check of sourcecode files">
<apply executable="php" taskname="lint">
<arg value="-l" />
<fileset dir="${basedir}/lib/Froxlor">
<include name="**/*.php" />
<modified />
</fileset>
<fileset dir="${basedir}/tests">
<include name="**/*.php" />
<modified />
</fileset>
</apply>
<property name="lint.done" value="true" />
</target>
<target name="phploc" unless="phploc.done"
description="Measure project size using PHPLOC and print human readable output. Intended for usage on the command line.">
<exec executable="${phploc}" taskname="phploc">
<arg value="--count-tests" />
<arg path="${basedir}/lib/Froxlor" />
<arg path="${basedir}/tests" />
</exec>
<property name="phploc.done" value="true" />
</target>
<target name="phploc-ci" unless="phploc.done" depends="prepare"
description="Measure project size using PHPLOC and log result in CSV and XML format. Intended for usage within a continuous integration environment.">
<exec executable="${phploc}" taskname="phploc">
<arg value="--count-tests" />
<arg value="--log-csv" />
<arg path="${basedir}/build/logs/phploc.csv" />
<arg value="--log-xml" />
<arg path="${basedir}/build/logs/phploc.xml" />
<arg path="${basedir}/lib/Froxlor" />
<arg path="${basedir}/tests" />
</exec>
<property name="phploc.done" value="true" />
</target>
<target name="pdepend" unless="pdepend.done" depends="prepare"
description="Calculate software metrics using PHP_Depend and log result in XML format. Intended for usage within a continuous integration environment.">
<exec executable="${pdepend}" taskname="pdepend">
<arg value="--jdepend-xml=${basedir}/build/logs/jdepend.xml" />
<arg
value="--jdepend-chart=${basedir}/build/pdepend/dependencies.svg" />
<arg
value="--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg" />
<arg path="${basedir}/lib/Froxlor" />
</exec>
<property name="pdepend.done" value="true" />
</target>
<target name="phpmd" unless="phpmd.done"
description="Perform project mess detection using PHPMD and print human readable output. Intended for usage on the command line before committing.">
<exec executable="${phpmd}" taskname="phpmd">
<arg path="${basedir}/lib/Froxlor" />
<arg value="text" />
<arg path="${basedir}/phpmd.xml" />
</exec>
<property name="phpmd.done" value="true" />
</target>
<target name="phpmd-ci" unless="phpmd.done" depends="prepare"
description="Perform project mess detection using PHPMD and log result in XML format. Intended for usage within a continuous integration environment.">
<exec executable="${phpmd}" taskname="phpmd">
<arg path="${basedir}/lib/Froxlor" />
<arg value="xml" />
<arg path="${basedir}/phpmd.xml" />
<arg value="--reportfile" />
<arg path="${basedir}/build/logs/pmd.xml" />
</exec>
<property name="phpmd.done" value="true" />
</target>
<target name="phpcs" unless="phpcs.done"
description="Find coding standard violations using PHP_CodeSniffer and print human readable output. Intended for usage on the command line before committing.">
<exec executable="${phpcs}" taskname="phpcs">
<arg value="--standard=${basedir}/phpcs.xml" />
<arg value="--extensions=php" />
<arg path="${basedir}/lib/Froxlor" />
<arg path="${basedir}/tests" />
</exec>
<property name="phpcs.done" value="true" />
</target>
<target name="phpcs-ci" unless="phpcs.done" depends="prepare"
description="Find coding standard violations using PHP_CodeSniffer and log result in XML format. Intended for usage within a continuous integration environment.">
<exec executable="${phpcs}" output="/dev/null" taskname="phpcs">
<arg value="--report=checkstyle" />
<arg
value="--report-file=${basedir}/build/logs/checkstyle-standard.xml" />
<arg value="--standard=${basedir}/phpcs.xml" />
<arg value="--extensions=php" />
<arg path="${basedir}/lib/Froxlor" />
<arg path="${basedir}/tests" />
</exec>
<property name="phpcs.done" value="true" />
</target>
<target name="phpcompat" unless="phpcompat.done"
depends="composer"
description="Find php violations using PHP_CodeSniffer and print human readable output. Intended for usage on the command line before committing.">
<exec executable="${phpcs}" taskname="phpcompat">
<arg
line="--standard=PHPCompatibility --runtime-set testVersion 5.6 ${basedir}/lib/Froxlor ${basedir}/tests" />
</exec>
<property name="phpcompat.done" value="true" />
</target>
<target name="phpcompat-ci" unless="phpcompat.done"
depends="composer"
description="Find php violations using PHP_CodeSniffer and log result in XML format. Intended for usage within a continuous integration environment.">
<exec executable="${phpcs}" output="/dev/null"
taskname="phpcompat">
<arg
line="--standard=PHPCompatibility --runtime-set testVersion 5.6 --report=checkstyle --report-file=${basedir}/build/logs/checkstyle-compat.xml ${basedir}/lib/Froxlor ${basedir}/tests" />
</exec>
<property name="phpcompat.done" value="true" />
</target>
<target name="phpcpd" unless="phpcpd.done"
description="Find duplicate code using PHPCPD and print human readable output. Intended for usage on the command line before committing.">
<exec executable="${phpcpd}" taskname="phpcpd">
<arg path="${basedir}/lib/Froxlor" />
</exec>
<property name="phpcpd.done" value="true" />
</target>
<target name="phpcpd-ci" unless="phpcpd.done" depends="prepare"
description="Find duplicate code using PHPCPD and log result in XML format. Intended for usage within a continuous integration environment.">
<exec executable="${phpcpd}" taskname="phpcpd">
<arg value="--log-pmd" />
<arg path="${basedir}/build/logs/pmd-cpd.xml" />
<arg path="${basedir}/lib/Froxlor" />
</exec>
<property name="phpcpd.done" value="true" />
</target>
<target name="phpunit-prepare" unless="phpunit-prepare.done" depends="composer"
description="prepare xdebug unit tests">
<exec executable="${phpunit}" resultproperty="result.phpunit-prepare"
taskname="phpunit">
<arg value="--configuration" />
<arg path="${basedir}/phpunit.xml" />
<arg value="--dump-xdebug-filter" />
<arg path="${basedir}/tests/xdebug-filter.php" />
</exec>
<property name="phpunit-prepare.done" value="true" />
</target>
<target name="phpunit" unless="phpunit.done" depends="phpunit-prepare"
description="Run unit tests with PHPUnit">
<exec executable="${phpunit}" failonerror="true" resultproperty="result.phpunit"
taskname="phpunit">
<arg value="--configuration" />
<arg path="${basedir}/phpunit.xml" />
<arg value="--testsuite" />
<arg value="froxlor" />
<arg value="--prepend" />
<arg path="${basedir}/tests/xdebug-filter.php" />
</exec>
<property name="phpunit.done" value="true" />
</target>
<target name="phpunit-no-coverage" unless="phpunit.done"
depends="composer"
description="Run unit tests with PHPUnit (without generating code coverage reports)">
<exec executable="${phpunit}" failonerror="true" resultproperty="result.phpunit"
taskname="phpunit">
<arg value="--configuration" />
<arg path="${basedir}/phpunit.xml" />
<arg value="--testsuite" />
<arg value="froxlor" />
<arg value="--no-coverage" />
</exec>
<property name="phpunit.done" value="true" />
</target>
<target name="-check-failure">
<fail message="PHPUnit did not finish successfully">
<condition>
<not>
<equals arg1="${result.phpunit}" arg2="0" />
</not>
</condition>
</fail>
</target>
</project>

2
cache/.gitignore vendored
View File

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

View File

@@ -1,86 +0,0 @@
{
"name": "froxlor/froxlor",
"description": "The server administration software for your needs. Developed by experienced server administrators, this panel simplifies the effort of managing your hosting platform.",
"keywords": [
"server",
"administration",
"php"
],
"homepage": "https://www.froxlor.org",
"license": "GPL-2.0-or-later",
"authors": [
{
"name": "Michael Kaufmann",
"email": "team@froxlor.org",
"role": "Lead Developer"
}
],
"support": {
"email": "team@froxlor.org",
"issues": "https://github.com/Froxlor/Froxlor/issues",
"forum": "https://forum.froxlor.org/",
"source": "https://github.com/Froxlor/Froxlor",
"docs": "https://docs.froxlor.org/",
"chat": "https://discord.froxlor.org/"
},
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/d00p"
}
],
"require": {
"php": "^7.4 || ^8.0",
"ext-session": "*",
"ext-ctype": "*",
"ext-pdo": "*",
"ext-pdo_mysql": "*",
"ext-simplexml": "*",
"ext-xml": "*",
"ext-filter": "*",
"ext-posix": "*",
"ext-mbstring": "*",
"ext-curl": "*",
"ext-json": "*",
"ext-openssl": "*",
"ext-fileinfo": "*",
"ext-gmp": "*",
"phpmailer/phpmailer": "~6.0",
"monolog/monolog": "^1.24",
"robthree/twofactorauth": "^1.6",
"froxlor/idna-convert-legacy": "^2.1",
"voku/anti-xss": "^4.1",
"twig/twig": "^3.3",
"erusev/parsedown": "^1.7",
"symfony/console": "^5.4"
},
"require-dev": {
"phpunit/phpunit": "^9",
"ext-pcntl": "*",
"phpcompatibility/php-compatibility": "*",
"squizlabs/php_codesniffer": "*",
"pdepend/pdepend": "^2.9",
"sebastian/phpcpd": "^6.0",
"phploc/phploc": "^7.0",
"phpmd/phpmd": "^2.10",
"phpunit/php-timer" : "^5",
"phpstan/phpstan": "^1.8"
},
"suggest": {
"ext-bcmath": "*",
"ext-zip": "*",
"ext-apcu": "*",
"ext-readline": "*"
},
"autoload": {
"psr-4": {
"Froxlor\\": [
"lib/Froxlor"
]
}
},
"scripts": {
"post-install-cmd": "if [ -f ./vendor/bin/phpcs ]; then \"vendor/bin/phpcs\" --config-set installed_paths vendor/phpcompatibility/php-compatibility ; fi",
"post-update-cmd" : "if [ -f ./vendor/bin/phpcs ]; then \"vendor/bin/phpcs\" --config-set installed_paths vendor/phpcompatibility/php-compatibility ; fi"
}
}

4696
composer.lock generated

File diff suppressed because it is too large Load Diff

35
customer_aps.php Normal file
View File

@@ -0,0 +1,35 @@
<?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 Panel
* @version $Id$
*/
// Required code
define('AREA', 'customer');
require ("./lib/init.php");
require ("./lib/class_apsparser.php");
$Id = 0;
if(isset($_GET['id']))$Id = (int)$_GET['id'];
if(isset($_POST['id']))$Id = (int)$_POST['id'];
eval("echo \"" . getTemplate("aps/header") . "\";");
$Aps = new ApsParser($userinfo, $settings, $db);
$Aps->MainHandler($action);
eval("echo \"" . getTemplate("aps/footer") . "\";");
?>

306
customer_autoresponder.php Normal file
View File

@@ -0,0 +1,306 @@
<?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 Panel
* @version $Id$
*/
// Required code
define('AREA', 'customer');
require ("./lib/init.php");
// Create new autoresponder
if($action == "add")
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$account = trim($_POST['account']);
$subject = trim($_POST['subject']);
$message = trim($_POST['message']);
$date_from_off = isset($_POST['date_from_off']) ? -1 : 0;
$date_until_off = isset($_POST['date_until_off']) ? -1 : 0;
/*
* @TODO validate date (DD-MM-YYYY)
*/
$ts_from = -1;
$ts_until = -1;
if($date_from_off > -1)
{
$date_from = $_POST['date_from'];
$ts_from = mktime(0, 0, 0, substr($date_from, 3, 2), substr($date_from, 0, 2), substr($date_from, 6, 4));
}
if($date_until_off > -1)
{
$date_until = $_POST['date_until'];
$ts_until = mktime(0, 0, 0, substr($date_until, 3, 2), substr($date_until, 0, 2), substr($date_until, 6, 4));
}
if(empty($account)
|| empty($subject)
|| empty($message))
{
standard_error('missingfields');
}
// Does account exist?
$result = $db->query("SELECT `email` FROM `" . TABLE_MAIL_USERS . "` WHERE `customerid` = '" . (int)$userinfo['customerid'] . "' AND `email` = '" . $db->escape($account) . "' LIMIT 0,1");
if($db->num_rows($result) == 0)
{
standard_error('accountnotexisting');
}
// Does autoresponder exist?
$result = $db->query("SELECT `email` FROM `" . TABLE_MAIL_AUTORESPONDER . "` WHERE `customerid` = '" . (int)$userinfo['customerid'] . "' AND `email` = '" . $db->escape($account) . "' LIMIT 0,1");
if($db->num_rows($result) == 1)
{
standard_error('autoresponderalreadyexists');
}
$db->query("INSERT INTO `" . TABLE_MAIL_AUTORESPONDER . "`
SET `email` = '" . $db->escape($account) . "',
`message` = '" . $db->escape($message) . "',
`enabled` = '" . (int)$_POST['active'] . "',
`date_from` = '" . (int)$ts_from . "',
`date_until` = '" . (int)$ts_until . "',
`subject` = '" . $db->escape($subject) . "',
`customerid` = '" . $db->escape((int)$userinfo['customerid']) . "'
");
redirectTo($filename, Array('s' => $s));
}
// Get accounts
$result = $db->query("SELECT `email` FROM `" . TABLE_MAIL_USERS . "` WHERE `customerid` = '" . (int)$userinfo['customerid'] . "' AND `email` NOT IN (SELECT `email` FROM `" . TABLE_MAIL_AUTORESPONDER . "`) ORDER BY email ASC");
if($db->num_rows($result) == 0)
{
standard_error('noemailaccount');
}
$accounts = '';
while($row = $db->fetch_array($result))
{
$accounts.= "<option value=\"" . $row['email'] . "\">" . $row['email'] . "</option>";
}
$date_from_off = makecheckbox('date_from_off', $lng['panel']['not_activated'], '-1', false, '-1', true, true);
$date_until_off = makecheckbox('date_from_off', $lng['panel']['not_activated'], '-1', false, '-1', true, true);
eval("echo \"" . getTemplate("email/autoresponder_add") . "\";");
}
// Edit autoresponder
else
if($action == "edit")
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$account = trim($_POST['account']);
$subject = trim($_POST['subject']);
$message = trim($_POST['message']);
$date_from_off = isset($_POST['date_from_off']) ? -1 : 0;
$date_until_off = isset($_POST['date_until_off']) ? -1 : 0;
/*
* @TODO validate date (DD-MM-YYYY)
*/
$ts_from = -1;
$ts_until = -1;
if($date_from_off > -1)
{
$date_from = $_POST['date_from'];
$ts_from = mktime(0, 0, 0, substr($date_from, 3, 2), substr($date_from, 0, 2), substr($date_from, 6, 4));
}
if($date_until_off > -1)
{
$date_until = $_POST['date_until'];
$ts_until = mktime(0, 0, 0, substr($date_until, 3, 2), substr($date_until, 0, 2), substr($date_until, 6, 4));
}
if(empty($account)
|| empty($subject)
|| empty($message))
{
standard_error('missingfields');
}
// Does account exist?
$result = $db->query("SELECT `email` FROM `" . TABLE_MAIL_USERS . "` WHERE `customerid` = '" . (int)$userinfo['customerid'] . "' AND `email` = '" . $db->escape($account) . "' LIMIT 0,1");
if($db->num_rows($result) == 0)
{
standard_error('accountnotexisting');
}
// Does autoresponder exist?
$result = $db->query("SELECT `email` FROM `" . TABLE_MAIL_AUTORESPONDER . "` WHERE `customerid` = '" . (int)$userinfo['customerid'] . "' AND `email` = '" . $db->escape($account) . "' LIMIT 0,1");
if($db->num_rows($result) == 0)
{
standard_error('invalidautoresponder');
}
$ResponderActive = 0;
if(isset($_POST['active'])
&& $_POST['active'] == '1')
{
$ResponderActive = 1;
}
$db->query("UPDATE `" . TABLE_MAIL_AUTORESPONDER . "`
SET `message` = '" . $db->escape($message) . "',
`enabled` = '" . (int)$ResponderActive . "',
`date_from` = '" . (int)$ts_from . "',
`date_until` = '" . (int)$ts_until . "',
`subject` = '" . $db->escape($subject) . "'
WHERE `email` = '" . $db->escape($account) . "'
AND `customerid` = '" . $db->escape((int)$userinfo['customerid']) . "'
");
redirectTo($filename, Array('s' => $s));
}
$email = trim(htmlspecialchars($_GET['email']));
// Get account data
$result = $db->query("SELECT * FROM `" . TABLE_MAIL_AUTORESPONDER . "` WHERE `customerid` = '" . (int)$userinfo['customerid'] . "' AND `email` = '" . $db->escape($email) . "' LIMIT 0,1");
if($db->num_rows($result) == 0)
{
standard_error('invalidautoresponder');
}
$row = $db->fetch_array($result);
$subject = htmlspecialchars($row['subject']);
$message = htmlspecialchars($row['message']);
$date_from = (int)$row['date_from'];
$date_until = (int)$row['date_until'];
if($date_from == -1)
{
$deactivated = '-1';
}
else
{
$deactivated = '0';
$date_from = date('d-m-Y', $date_from);
}
$date_from_off = makecheckbox('date_from_off', $lng['panel']['not_activated'], '-1', false, $deactivated, true, true);
if($date_until == -1)
{
$deactivated = '-1';
$date_until = '-1';
}
else
{
$deactivated = '0';
$date_until = date('d-m-Y', $date_until);
}
$date_from_off = makecheckbox('date_until_off', $lng['panel']['not_activated'], '-1', false, $deactivated, true, true);
$checked = '';
if($row['enabled'] == 1)
{
$checked = "checked=\"checked\"";
}
eval("echo \"" . getTemplate("email/autoresponder_edit") . "\";");
}
// Delete autoresponder
else
if($action == "delete")
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$account = trim($_POST['account']);
// Does autoresponder exist?
$result = $db->query("SELECT `email` FROM `" . TABLE_MAIL_AUTORESPONDER . "` WHERE `customerid` = '" . (int)$userinfo['customerid'] . "' AND `email` = '" . $db->escape($account) . "' LIMIT 0,1");
if($db->num_rows($result) == 0)
{
standard_error('invalidautoresponder');
}
$db->query("DELETE FROM `" . TABLE_MAIL_AUTORESPONDER . "`
WHERE `email` = '" . $db->escape($account) . "'
AND `customerid` = '" . $db->escape((int)$userinfo['customerid']) . "'
");
redirectTo($filename, Array('s' => $s));
}
$email = trim(htmlspecialchars($_GET['email']));
ask_yesno('autoresponderdelete', $filename, array('action' => $action, 'account' => $email));
}
// List existing autoresponders
else
{
$autoresponder = '';
$result = $db->query("SELECT * FROM `" . TABLE_MAIL_AUTORESPONDER . "` WHERE `customerid` = '" . (int)$userinfo['customerid'] . "' ORDER BY email ASC");
while($row = $db->fetch_array($result))
{
if($row['date_from'] == -1 && $row['date_until'] == -1)
{
$activated_date = $lng['panel']['not_activated'];
}
elseif($row['date_from'] == -1 && $row['date_until'] != -1)
{
$activated_date = $lng['autoresponder']['date_until'].': '.date('d-m-Y', $row['date_until']);
}
elseif($row['date_from'] != -1 && $row['date_until'] == -1)
{
$activated_date = $lng['autoresponder']['date_from'].': '.date('d-m-Y', $row['date_from']);
}
else
{
$activated_date = date('d-m-Y', $row['date_from']) . ' - ' . date('d-m-Y', $row['date_until']);
}
eval("\$autoresponder.=\"" . getTemplate("email/autoresponder_autoresponder") . "\";");
}
eval("echo \"" . getTemplate("email/autoresponder") . "\";");
}
?>

View File

@@ -2,385 +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 * @version $Id$
* 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 = 'customer'; define('AREA', 'customer');
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\SubDomains as SubDomains; /**
use Froxlor\Database\Database; * Include our init.php, which manages Sessions, Language etc.
use Froxlor\Domain\Domain; */
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;
use Froxlor\Validate\Validate;
use Froxlor\CurrentUser;
// redirect if this customer page is hidden via settings require ("./lib/init.php");
if (Settings::IsInList('panel.customer_hide_options', 'domains')) {
Response::redirectTo('customer_index.php'); if(isset($_POST['id']))
{
$id = intval($_POST['id']);
}
elseif(isset($_GET['id']))
{
$id = intval($_GET['id']);
} }
$id = (int)Request::any('id'); if($page == 'overview')
{
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_domains");
eval("echo \"" . getTemplate("domains/domains") . "\";");
}
elseif($page == 'domains')
{
if($action == '')
{
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_domains::domains");
$fields = array(
'd.domain' => $lng['domains']['domainname'],
'd.documentroot' => $lng['panel']['path'],
'd.aliasdomain' => $lng['domains']['aliasdomain']
);
$paging = new paging($userinfo, $db, TABLE_PANEL_DOMAINS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
$result = $db->query("SELECT `d`.`id`, `d`.`customerid`, `d`.`domain`, `d`.`documentroot`, `d`.`isemaildomain`, `d`.`caneditdomain`, `d`.`iswildcarddomain`, `d`.`parentdomainid`, `ad`.`id` AS `aliasdomainid`, `ad`.`domain` AS `aliasdomain`, `da`.`id` AS `domainaliasid`, `da`.`domain` AS `domainalias` FROM `" . TABLE_PANEL_DOMAINS . "` `d` LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `ad` ON `d`.`aliasdomain`=`ad`.`id` LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `da` ON `da`.`aliasdomain`=`d`.`id` WHERE `d`.`customerid`='" . (int)$userinfo['customerid'] . "' AND `d`.`email_only`='0' AND `d`.`id` <> " . (int)$userinfo['standardsubdomain'] . " " . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
$paging->setEntries($db->num_rows($result));
$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 = 0;
$domain_array = array();
if ($page == 'overview' || $page == 'domains') { while($row = $db->fetch_array($result))
if ($action == '') { {
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_domains::domains"); $row['domain'] = $idna_convert->decode($row['domain']);
$row['aliasdomain'] = $idna_convert->decode($row['aliasdomain']);
$row['domainalias'] = $idna_convert->decode($row['domainalias']);
$parentdomain_id = (int)Request::any('pid', '0'); if($row['parentdomainid'] == '0'
&& $row['iswildcarddomain'] != '1'
try { && $row['caneditdomain'] == '1')
$domain_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.domains.php'; {
$collection = (new Collection(SubDomains::class, $userinfo)) $parentdomains_count++;
->withPagination($domain_list_data['domain_list']['columns'], $domain_list_data['domain_list']['default_sorting']);
$parentDomainCollection = (new Collection(SubDomains::class, $userinfo, ['sql_search' => ['d.parentdomainid' => 0]]));
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
$actions_links = false;
if (CurrentUser::canAddResource('subdomains')) {
$actions_links = [
[
'href' => $linker->getLink(['section' => 'domains', 'page' => 'domains', 'action' => 'add']),
'label' => lng('domains.subdomain_add')
]
];
}
UI::view('user/table.html.twig', [
'listing' => Listing::format($collection, $domain_list_data, 'domain_list'),
'actions_links' => $actions_links,
'entity_info' => lng('domains.description')
]);
} elseif ($action == 'delete' && $id != 0) {
try {
$json_result = SubDomains::getLocal($userinfo, [
'id' => $id
])->get();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$alias_stmt = Database::prepare("SELECT COUNT(`id`) AS `count` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `aliasdomain` = :aliasdomain");
$alias_check = Database::pexecute_first($alias_stmt, [
"aliasdomain" => $id
]);
if (isset($result['parentdomainid']) && $result['parentdomainid'] != '0' && $alias_check['count'] == 0) {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
try {
SubDomains::getLocal($userinfo, $_POST)->delete();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
Response::redirectTo($filename, [
'page' => $page
]);
} else {
HTML::askYesNo('domains_reallydelete', $filename, [
'id' => $id,
'page' => $page,
'action' => $action
], $idna_convert->decode($result['domain']));
}
} else {
Response::standardError('domains_cantdeletemaindomain');
}
} elseif ($action == 'add') {
if ($userinfo['subdomains_used'] < $userinfo['subdomains'] || $userinfo['subdomains'] == '-1') {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
try {
SubDomains::getLocal($userinfo, $_POST)->add();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
Response::redirectTo($filename, [
'page' => $page
]);
} else {
$stmt = Database::prepare("SELECT `id`, `domain`, `documentroot`, `ssl_redirect`,`isemaildomain`,`letsencrypt` FROM `" . TABLE_PANEL_DOMAINS . "`
WHERE `customerid` = :customerid
AND `parentdomainid` = '0'
AND `email_only` = '0'
AND `caneditdomain` = '1'
ORDER BY `domain` ASC");
Database::pexecute($stmt, [
"customerid" => $userinfo['customerid']
]);
$domains = [];
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$domains[$row['domain']] = $idna_convert->decode($row['domain']);
}
$aliasdomains[0] = lng('domains.noaliasdomain');
$domains_stmt = Database::prepare("SELECT `d`.`id`, `d`.`domain` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c`
WHERE `d`.`aliasdomain` IS NULL
AND `d`.`id` <> `c`.`standardsubdomain`
AND `d`.`parentdomainid` = '0'
AND `d`.`customerid`=`c`.`customerid`
AND `d`.`email_only`='0'
AND `d`.`customerid`= :customerid
ORDER BY `d`.`domain` ASC");
Database::pexecute($domains_stmt, [
"customerid" => $userinfo['customerid']
]);
while ($row_domain = $domains_stmt->fetch(PDO::FETCH_ASSOC)) {
$aliasdomains[$row_domain['id']] = $idna_convert->decode($row_domain['domain']);
}
$redirectcode = [];
if (Settings::Get('customredirect.enabled') == '1') {
$codes = Domain::getRedirectCodesArray();
foreach ($codes as $rc) {
$redirectcode[$rc['id']] = $rc['code'] . ' (' . lng('redirect_desc.' . $rc['desc']) . ')';
}
}
// check if we at least have one ssl-ip/port, #1179
$ssl_ipsandports = false;
$ssl_ip_stmt = Database::prepare("
SELECT COUNT(*) as countSSL
FROM `" . TABLE_PANEL_IPSANDPORTS . "` pip
LEFT JOIN `" . TABLE_DOMAINTOIP . "` dti ON dti.id_ipandports = pip.id
WHERE pip.`ssl`='1'
");
Database::pexecute($ssl_ip_stmt);
$resultX = $ssl_ip_stmt->fetch(PDO::FETCH_ASSOC);
if (isset($resultX['countSSL']) && (int)$resultX['countSSL'] > 0) {
$ssl_ipsandports = true;
}
$openbasedir = [
0 => lng('domain.docroot'),
1 => lng('domain.homedir'),
2 => lng('domain.docparent')
];
$pathSelect = FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']);
$phpconfigs = [];
if (isset($userinfo['allowed_phpconfigs']) && !empty($userinfo['allowed_phpconfigs'])) {
$allowed_cfg = json_decode($userinfo['allowed_phpconfigs'], JSON_OBJECT_AS_ARRAY);
$phpconfigs_result_stmt = Database::query("
SELECT c.*, fc.description as interpreter
FROM `" . TABLE_PANEL_PHPCONFIGS . "` c
LEFT JOIN `" . TABLE_PANEL_FPMDAEMONS . "` fc ON fc.id = c.fpmsettingid
WHERE c.id IN (" . implode(", ", $allowed_cfg) . ")
");
while ($phpconfigs_row = $phpconfigs_result_stmt->fetch(PDO::FETCH_ASSOC)) {
if ((int)Settings::Get('phpfpm.enabled') == 1) {
$phpconfigs[$phpconfigs_row['id']] = $phpconfigs_row['description'] . " [" . $phpconfigs_row['interpreter'] . "]";
} else {
$phpconfigs[$phpconfigs_row['id']] = $phpconfigs_row['description'];
}
}
}
$subdomain_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/domains/formfield.domains_add.php';
UI::view('user/form.html.twig', [
'formaction' => $linker->getLink(['section' => 'domains']),
'formdata' => $subdomain_add_data['domain_add']
]);
}
}
} elseif ($action == 'edit' && $id != 0) {
try {
$json_result = SubDomains::getLocal($userinfo, [
'id' => $id
])->get();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
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') { $domains_count++;
try { $domainparts = explode('.', $row['domain']);
SubDomains::getLocal($userinfo, $_POST)->update(); $domainparts = array_reverse($domainparts);
} catch (Exception $e) { $sortkey = '';
Response::dynamicError($e->getMessage()); foreach($domainparts as $key => $part)
} {
Response::redirectTo($filename, [ $sortkey.= $part . '.';
'page' => $page
]);
} else {
$result['domain'] = $idna_convert->decode($result['domain']);
$domains[0] = lng('domains.noaliasdomain');
// 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`
WHERE `d`.`aliasdomain` IS NULL
AND `d`.`id` <> :id
AND `c`.`standardsubdomain` <> `d`.`id`
AND `d`.`parentdomainid` = '0'
AND `d`.`customerid` = :customerid
AND `c`.`customerid` = `d`.`customerid`
AND `d`.`id` = `dip`.`id_domain`
AND `dip`.`id_ipandports`
IN (SELECT `id_ipandports` FROM `" . TABLE_DOMAINTOIP . "`
WHERE `id_domain` = :id)
GROUP BY `d`.`id`, `d`.`domain`
ORDER BY `d`.`domain` ASC");
Database::pexecute($domains_stmt, [
"id" => $result['id'],
"customerid" => $userinfo['customerid']
]);
while ($row_domain = $domains_stmt->fetch(PDO::FETCH_ASSOC)) {
$domains[$row_domain['id']] = $idna_convert->decode($row_domain['domain']);
}
if (preg_match('/^https?\:\/\//', $result['documentroot']) && Validate::validateUrl($result['documentroot'])) {
if (Settings::Get('panel.pathedit') == 'Dropdown') {
$urlvalue = $result['documentroot'];
$pathSelect = FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']);
} else {
$urlvalue = '';
$pathSelect = FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $result['documentroot'], true);
}
} else {
$urlvalue = '';
$pathSelect = FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $result['documentroot']);
}
$redirectcode = [];
if (Settings::Get('customredirect.enabled') == '1') {
$def_code = Domain::getDomainRedirectId($id);
$codes = Domain::getRedirectCodesArray();
foreach ($codes as $rc) {
$redirectcode[$rc['id']] = $rc['code'] . ' (' . lng('redirect_desc.' . $rc['desc']) . ')';
}
}
// check if we at least have one ssl-ip/port, #1179
$ssl_ipsandports = false;
$ssl_ip_stmt = Database::prepare("
SELECT COUNT(*) as countSSL
FROM `" . TABLE_PANEL_IPSANDPORTS . "` pip
LEFT JOIN `" . TABLE_DOMAINTOIP . "` dti ON dti.id_ipandports = pip.id
WHERE `dti`.`id_domain` = :id_domain AND pip.`ssl`='1'
");
Database::pexecute($ssl_ip_stmt, [
"id_domain" => $result['id']
]);
$resultX = $ssl_ip_stmt->fetch(PDO::FETCH_ASSOC);
if (isset($resultX['countSSL']) && (int)$resultX['countSSL'] > 0) {
$ssl_ipsandports = true;
}
// Fudge the result for ssl_redirect to hide the Let's Encrypt steps
$result['temporary_ssl_redirect'] = $result['ssl_redirect'];
$result['ssl_redirect'] = ($result['ssl_redirect'] == 0 ? 0 : 1);
$openbasedir = [
0 => lng('domain.docroot'),
1 => lng('domain.homedir'),
2 => lng('domain.docparent')
];
// create serveralias options
$serveraliasoptions = [];
$serveraliasoptions_selected = '2';
if ($result['iswildcarddomain'] == '1') {
$serveraliasoptions_selected = '0';
} elseif ($result['wwwserveralias'] == '1') {
$serveraliasoptions_selected = '1';
}
$serveraliasoptions[0] = lng('domains.serveraliasoption_wildcard');
$serveraliasoptions[1] = lng('domains.serveraliasoption_www');
$serveraliasoptions[2] = lng('domains.serveraliasoption_none');
$ips_stmt = Database::prepare("SELECT `p`.`ip` AS `ip` FROM `" . TABLE_PANEL_IPSANDPORTS . "` `p`
LEFT JOIN `" . TABLE_DOMAINTOIP . "` `dip`
ON ( `dip`.`id_ipandports` = `p`.`id` )
WHERE `dip`.`id_domain` = :id_domain
GROUP BY `p`.`ip`");
Database::pexecute($ips_stmt, [
"id_domain" => $result['id']
]);
$domainips = [];
while ($rowip = $ips_stmt->fetch(PDO::FETCH_ASSOC)) {
$domainips[] = ['item' => $rowip['ip']];
}
$phpconfigs = [];
if (isset($userinfo['allowed_phpconfigs']) && !empty($userinfo['allowed_phpconfigs'])) {
$allowed_cfg = json_decode($userinfo['allowed_phpconfigs'], JSON_OBJECT_AS_ARRAY);
$phpconfigs_result_stmt = Database::query("
SELECT c.*, fc.description as interpreter
FROM `" . TABLE_PANEL_PHPCONFIGS . "` c
LEFT JOIN `" . TABLE_PANEL_FPMDAEMONS . "` fc ON fc.id = c.fpmsettingid
WHERE c.id IN (" . implode(", ", $allowed_cfg) . ")
");
while ($phpconfigs_row = $phpconfigs_result_stmt->fetch(PDO::FETCH_ASSOC)) {
if ((int)Settings::Get('phpfpm.enabled') == 1) {
$phpconfigs[$phpconfigs_row['id']] = $phpconfigs_row['description'] . " [" . $phpconfigs_row['interpreter'] . "]";
} else {
$phpconfigs[$phpconfigs_row['id']] = $phpconfigs_row['description'];
}
}
}
$alias_stmt = Database::prepare("SELECT COUNT(`id`) AS count FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `aliasdomain`= :aliasdomain");
$alias_check = Database::pexecute_first($alias_stmt, [
"aliasdomain" => $result['id']
]);
$alias_check = $alias_check['count'];
$result = PhpHelper::htmlentitiesArray($result);
$subdomain_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/domains/formfield.domains_edit.php';
UI::view('user/form.html.twig', [
'formaction' => $linker->getLink(['section' => 'domains', 'id' => $id]),
'formdata' => $subdomain_edit_data['domain_edit'],
'editid' => $id
]);
} }
} else {
Response::standardError('domains_canteditdomain'); $domain_array[$sortkey] = $row;
}
ksort($domain_array);
$domain_id_array = array();
foreach($domain_array as $sortkey => $row)
{
$domain_id_array[$row['id']] = $sortkey;
}
$domain_sort_array = array();
foreach($domain_array as $sortkey => $row)
{
if($row['parentdomainid'] == 0)
{
$domain_sort_array[$sortkey][$sortkey] = $row;
}
else
{
$domain_sort_array[$domain_id_array[$row['parentdomainid']]][$sortkey] = $row;
}
}
$domain_array = array();
if($paging->sortfield == 'd.domain'
&& $paging->sortorder == 'asc')
{
ksort($domain_sort_array);
}
elseif($paging->sortfield == 'd.domain'
&& $paging->sortorder == 'desc')
{
krsort($domain_sort_array);
}
$i = 0;
foreach($domain_sort_array as $sortkey => $domain_array)
{
if($paging->checkDisplay($i))
{
$row = htmlentities_array($domain_array[$sortkey]);
eval("\$domains.=\"" . getTemplate("domains/domains_delimiter") . "\";");
if($paging->sortfield == 'd.domain'
&& $paging->sortorder == 'asc')
{
ksort($domain_array);
}
elseif($paging->sortfield == 'd.domain'
&& $paging->sortorder == 'desc')
{
krsort($domain_array);
}
foreach($domain_array as $row)
{
if(strpos($row['documentroot'], $userinfo['documentroot']) === 0)
{
$row['documentroot'] = makeCorrectDir(substr($row['documentroot'], strlen($userinfo['documentroot'])));
}
$row = htmlentities_array($row);
eval("\$domains.=\"" . getTemplate("domains/domains_domain") . "\";");
}
}
$i+= count($domain_array);
}
eval("echo \"" . getTemplate("domains/domainlist") . "\";");
}
elseif($action == 'delete'
&& $id != 0)
{
$result = $db->query_first("SELECT `id`, `customerid`, `domain`, `documentroot`, `isemaildomain`, `parentdomainid` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'");
$alias_check = $db->query_first('SELECT COUNT(`id`) AS `count` FROM `' . TABLE_PANEL_DOMAINS . '` WHERE `aliasdomain`=\'' . (int)$id . '\'');
if(isset($result['parentdomainid'])
&& $result['parentdomainid'] != '0'
&& $alias_check['count'] == 0)
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
if($result['isemaildomain'] == '1')
{
$emails = $db->query_first('SELECT COUNT(`id`) AS `count` FROM `' . TABLE_MAIL_VIRTUAL . '` WHERE `customerid`=\'' . (int)$userinfo['customerid'] . '\' AND `domainid`=\'' . (int)$id . '\'');
if($emails['count'] != '0')
{
standard_error('domains_cantdeletedomainwithemail');
}
}
$log->logAction(USR_ACTION, LOG_INFO, "deleted subdomain '" . $idna_convert->decode($result['domain']) . "'");
$result = $db->query("DELETE FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'");
$result = $db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `subdomains_used`=`subdomains_used`-1 WHERE `customerid`='" . (int)$userinfo['customerid'] . "'");
inserttask('1');
inserttask('4');
redirectTo($filename, Array('page' => $page, 's' => $s));
}
else
{
ask_yesno('domains_reallydelete', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $idna_convert->decode($result['domain']));
}
}
else
{
standard_error('domains_cantdeletemaindomain');
}
}
elseif($action == 'add')
{
if($userinfo['subdomains_used'] < $userinfo['subdomains']
|| $userinfo['subdomains'] == '-1')
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$subdomain = $idna_convert->encode(preg_replace(Array('/\:(\d)+$/', '/^https?\:\/\//'), '', validate($_POST['subdomain'], 'subdomain', '', 'subdomainiswrong')));
$domain = $idna_convert->encode($_POST['domain']);
$domain_check = $db->query_first("SELECT * FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `domain`='" . $db->escape($domain) . "' AND `customerid`='" . (int)$userinfo['customerid'] . "' AND `parentdomainid`='0' AND `email_only`='0' AND `iswildcarddomain`='0' AND `caneditdomain`='1' ");
$completedomain = $subdomain . '.' . $domain;
$completedomain_check = $db->query_first("SELECT * FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `domain`='" . $db->escape($completedomain) . "' AND `customerid`='" . (int)$userinfo['customerid'] . "' AND `email_only`='0' AND `caneditdomain` = '1'");
$aliasdomain = intval($_POST['alias']);
$aliasdomain_check = array(
'id' => 0
);
if($aliasdomain != 0)
{
$aliasdomain_check = $db->query_first('SELECT `id` FROM `' . TABLE_PANEL_DOMAINS . '` `d`,`' . TABLE_PANEL_CUSTOMERS . '` `c` WHERE `d`.`customerid`=\'' . (int)$userinfo['customerid'] . '\' AND `d`.`aliasdomain` IS NULL AND `d`.`id`<>`c`.`standardsubdomain` AND `c`.`customerid`=\'' . (int)$userinfo['customerid'] . '\' AND `d`.`id`=\'' . (int)$aliasdomain . '\'');
}
if(isset($_POST['url'])
&& $_POST['url'] != ''
&& validateUrl($idna_convert->encode($_POST['url'])))
{
$path = $_POST['url'];
}
else
{
$path = validate($_POST['path'], 'path');
}
if(!preg_match('/^https?\:\/\//', $path)
|| !validateUrl($idna_convert->encode($path)))
{
$path = $userinfo['documentroot'] . '/' . $path;
$path = makeCorrectDir($path);
}
if(isset($_POST['openbasedir_path'])
&& $_POST['openbasedir_path'] == '1')
{
$openbasedir_path = '1';
}
else
{
$openbasedir_path = '0';
}
if(isset($_POST['ssl_redirect'])
&& $_POST['ssl_redirect'] == '1')
{
$ssl_redirect = '1';
}
else
{
$ssl_redirect = '0';
}
if($path == '')
{
standard_error('patherror');
}
elseif($subdomain == '')
{
standard_error(array('stringisempty', 'domainname'));
}
elseif($subdomain == 'www' && $domain_check['wwwserveralias'] == '1')
{
standard_error('wwwnotallowed');
}
elseif($domain == '')
{
standard_error('domaincantbeempty');
}
elseif(strtolower($completedomain_check['domain']) == strtolower($completedomain))
{
standard_error('domainexistalready', $completedomain);
}
elseif(strtolower($domain_check['domain']) != strtolower($domain))
{
standard_error('maindomainnonexist', $domain);
}
elseif($aliasdomain_check['id'] != $aliasdomain)
{
standard_error('domainisaliasorothercustomer');
}
else
{
$result = $db->query("INSERT INTO `" . TABLE_PANEL_DOMAINS . "` (`customerid`, `domain`, `documentroot`, `ipandport`, `aliasdomain`, `parentdomainid`, `isemaildomain`, `openbasedir`, `openbasedir_path`, `safemode`, `speciallogfile`, `specialsettings`, `ssl_redirect`) VALUES ('" . (int)$userinfo['customerid'] . "', '" . $db->escape($completedomain) . "', '" . $db->escape($path) . "', '" . $db->escape($domain_check['ipandport']) . "', " . (($aliasdomain != 0) ? "'" . $db->escape($aliasdomain) . "'" : "NULL") . ", '" . (int)$domain_check['id'] . "', '" . ($domain_check['subcanemaildomain'] == '3' ? '1' : '0') . "', '" . $db->escape($domain_check['openbasedir']) . "', '" . $db->escape($openbasedir_path) . "', '" . $db->escape($domain_check['safemode']) . "', '" . $db->escape($domain_check['speciallogfile']) . "', '" . $db->escape($domain_check['specialsettings']) . "', '" . $ssl_redirect . "')");
$result = $db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `subdomains_used`=`subdomains_used`+1 WHERE `customerid`='" . (int)$userinfo['customerid'] . "'");
$log->logAction(USR_ACTION, LOG_INFO, "added subdomain '" . $completedomain . "'");
inserttask('1');
inserttask('4');
redirectTo($filename, Array('page' => $page, 's' => $s));
}
}
else
{
$result = $db->query("SELECT `id`, `domain`, `documentroot`, `ssl_redirect`,`isemaildomain` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `parentdomainid`='0' AND `email_only`='0' AND `iswildcarddomain`='0' AND `caneditdomain`='1' ORDER BY `domain` ASC");
$domains = '';
while($row = $db->fetch_array($result))
{
$domains.= makeoption($idna_convert->decode($row['domain']), $row['domain']);
}
$aliasdomains = makeoption($lng['domains']['noaliasdomain'], 0, NULL, true);
$result_domains = $db->query("SELECT `d`.`id`, `d`.`domain` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c` WHERE `d`.`aliasdomain` IS NULL AND `d`.`id` <> `c`.`standardsubdomain` AND `d`.`customerid`=`c`.`customerid` AND `d`.`email_only`='0' AND `d`.`customerid`=" . (int)$userinfo['customerid'] . " ORDER BY `d`.`domain` ASC");
while($row_domain = $db->fetch_array($result_domains))
{
$aliasdomains.= makeoption($idna_convert->decode($row_domain['domain']), $row_domain['id']);
}
$ssl_redirect = makeyesno('ssl_redirect', '1', '0', $result['ssl_redirect']);
$openbasedir = makeoption($lng['domain']['docroot'], 0, NULL, true) . makeoption($lng['domain']['homedir'], 1, NULL, true);
$pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $settings['panel']['pathedit']);
eval("echo \"" . getTemplate("domains/domains_add") . "\";");
}
}
}
elseif($action == 'edit'
&& $id != 0)
{
$result = $db->query_first("SELECT `d`.`id`, `d`.`customerid`, `d`.`domain`, `d`.`documentroot`, `d`.`isemaildomain`, `d`.`iswildcarddomain`, `d`.`parentdomainid`, `d`.`ssl_redirect`, `d`.`aliasdomain`, `d`.`openbasedir_path` ,`pd`.`subcanemaildomain` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_DOMAINS . "` `pd` WHERE `d`.`customerid`='" . (int)$userinfo['customerid'] . "' AND `d`.`id`='" . (int)$id . "' AND ((`d`.`parentdomainid`!='0' AND `pd`.`id`=`d`.`parentdomainid`) OR (`d`.`parentdomainid`='0' AND `pd`.`id`=`d`.`id`)) AND `d`.`caneditdomain`='1'");
$alias_check = $db->query_first('SELECT COUNT(`id`) AS count FROM `' . TABLE_PANEL_DOMAINS . '` WHERE `aliasdomain`=\'' . (int)$result['id'] . '\'');
$alias_check = $alias_check['count'];
if(isset($result['customerid'])
&& $result['customerid'] == $userinfo['customerid'])
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
if(isset($_POST['url'])
&& $_POST['url'] != ''
&& validateUrl($idna_convert->encode($_POST['url'])))
{
$path = $_POST['url'];
}
else
{
$path = validate($_POST['path'], 'path');
}
if(!preg_match('/^https?\:\/\//', $path)
|| !validateUrl($idna_convert->encode($path)))
{
$path = $userinfo['documentroot'] . '/' . $path;
$path = makeCorrectDir($path);
}
$aliasdomain = intval($_POST['alias']);
if(isset($_POST['iswildcarddomain'])
&& $_POST['iswildcarddomain'] == '1'
&& $result['parentdomainid'] == '0'
&& $userinfo['subdomains'] != '0')
{
$wildcarddomaincheck = $db->query("SELECT `id` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `parentdomainid` = '" . (int)$result['id'] . "'");
if($db->num_rows($wildcarddomaincheck) != '0')
{
standard_error('firstdeleteallsubdomains');
exit;
}
$iswildcarddomain = '1';
}
else
{
$iswildcarddomain = '0';
}
if($result['parentdomainid'] != '0'
&& ($result['subcanemaildomain'] == '1' || $result['subcanemaildomain'] == '2')
&& isset($_POST['isemaildomain']))
{
$isemaildomain = intval($_POST['isemaildomain']);
}
else
{
$isemaildomain = $result['isemaildomain'];
}
$aliasdomain_check = array(
'id' => 0
);
if($aliasdomain != 0)
{
$aliasdomain_check = $db->query_first('SELECT `id` FROM `' . TABLE_PANEL_DOMAINS . '` `d`,`' . TABLE_PANEL_CUSTOMERS . '` `c` WHERE `d`.`customerid`=\'' . (int)$result['customerid'] . '\' AND `d`.`aliasdomain` IS NULL AND `d`.`id`<>`c`.`standardsubdomain` AND `c`.`customerid`=\'' . (int)$result['customerid'] . '\' AND `d`.`id`=\'' . (int)$aliasdomain . '\'');
}
if($aliasdomain_check['id'] != $aliasdomain)
{
standard_error('domainisaliasorothercustomer');
}
if(isset($_POST['openbasedir_path'])
&& $_POST['openbasedir_path'] == '1')
{
$openbasedir_path = '1';
}
else
{
$openbasedir_path = '0';
}
if(isset($_POST['ssl_redirect'])
&& $_POST['ssl_redirect'] == '1')
{
$ssl_redirect = '1';
}
else
{
$ssl_redirect = '0';
}
if($path == '')
{
standard_error('patherror');
}
else
{
if(($result['isemaildomain'] == '1')
&& ($isemaildomain == '0'))
{
$db->query("DELETE FROM `" . TABLE_MAIL_USERS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `domainid`='" . (int)$id . "'");
$db->query("DELETE FROM `" . TABLE_MAIL_VIRTUAL . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `domainid`='" . (int)$id . "'");
$log->logAction(USR_ACTION, LOG_NOTICE, "automatically deleted mail-table entries for '" . $idna_convert->decode($result['domain']) . "'");
}
if($path != $result['documentroot']
|| $isemaildomain != $result['isemaildomain']
|| $iswildcarddomain != $result['iswildcarddomain']
|| $aliasdomain != $result['aliasdomain']
|| $openbasedir_path != $result['openbasedir_path']
|| $ssl_redirect != $result['ssl_redirect'])
{
$log->logAction(USR_ACTION, LOG_INFO, "edited domain '" . $idna_convert->decode($result['domain']) . "'");
inserttask('1');
inserttask('4');
$result = $db->query("UPDATE `" . TABLE_PANEL_DOMAINS . "` SET `documentroot`='" . $db->escape($path) . "', `isemaildomain`='" . (int)$isemaildomain . "', `iswildcarddomain`='" . (int)$iswildcarddomain . "', `aliasdomain`=" . (($aliasdomain != 0 && $alias_check == 0) ? '\'' . $db->escape($aliasdomain) . '\'' : 'NULL') . ",`openbasedir_path`='" . $db->escape($openbasedir_path) . "', `ssl_redirect`='" . $ssl_redirect . "' WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'");
}
redirectTo($filename, Array('page' => $page, 's' => $s));
}
}
else
{
$result['domain'] = $idna_convert->decode($result['domain']);
$domains = makeoption($lng['domains']['noaliasdomain'], 0, $result['aliasdomain'], true);
$result_domains = $db->query("SELECT `d`.`id`, `d`.`domain` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c` WHERE `d`.`aliasdomain` IS NULL AND `d`.`id`<>'" . (int)$result['id'] . "' AND `c`.`standardsubdomain`<>`d`.`id` AND `d`.`customerid`='" . (int)$userinfo['customerid'] . "' AND `c`.`customerid`=`d`.`customerid` ORDER BY `d`.`domain` ASC");
while($row_domain = $db->fetch_array($result_domains))
{
$domains.= makeoption($idna_convert->decode($row_domain['domain']), $row_domain['id'], $result['aliasdomain']);
}
if(preg_match('/^https?\:\/\//', $result['documentroot'])
&& validateUrl($idna_convert->encode($result['documentroot']))
&& $settings['panel']['pathedit'] == 'Dropdown')
{
$urlvalue = $result['documentroot'];
$pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $settings['panel']['pathedit']);
}
else
{
$urlvalue = '';
$pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $settings['panel']['pathedit'], $result['documentroot']);
}
$ssl_redirect = makeyesno('ssl_redirect', '1', '0', $result['ssl_redirect']);
$iswildcarddomain = makeyesno('iswildcarddomain', '1', '0', $result['iswildcarddomain']);
$isemaildomain = makeyesno('isemaildomain', '1', '0', $result['isemaildomain']);
$openbasedir = makeoption($lng['domain']['docroot'], 0, $result['openbasedir_path'], true) . makeoption($lng['domain']['homedir'], 1, $result['openbasedir_path'], true);
$result = htmlentities_array($result);
if($settings['system']['use_ssl'] == "1")
{
}
eval("echo \"" . getTemplate("domains/domains_edit") . "\";");
}
}
else
{
standard_error('domains_canteditdomain');
} }
} }
} elseif ($page == 'domainssleditor') {
require_once __DIR__ . '/ssl_editor.php';
} elseif ($page == 'domaindnseditor' && $userinfo['dnsenabled'] == '1' && Settings::Get('system.dnsenabled') == '1') {
require_once __DIR__ . '/dns_editor.php';
} elseif ($page == 'sslcertificates') {
require_once __DIR__ . '/ssl_certificates.php';
} elseif ($page == 'logfiles') {
require_once __DIR__ . '/logfiles_viewer.php';
} }
?>

File diff suppressed because it is too large Load Diff

View File

@@ -2,343 +2,427 @@
/** /**
* 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 * @version $Id$
* 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 = 'customer'; define('AREA', 'customer');
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\CustomerBackups as CustomerBackups; /**
use Froxlor\Api\Commands\DirOptions as DirOptions; * Include our init.php, which manages Sessions, Language etc.
use Froxlor\Api\Commands\DirProtections as DirProtections; */
use Froxlor\Customer\Customer;
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 require ("./lib/init.php");
if (Settings::IsInList('panel.customer_hide_options', 'extras')) {
Response::redirectTo('customer_index.php'); if(isset($_POST['id']))
{
$id = intval($_POST['id']);
}
elseif(isset($_GET['id']))
{
$id = intval($_GET['id']);
} }
$id = (int)Request::any('id'); if($page == 'overview')
{
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_extras");
eval("echo \"" . getTemplate("extras/extras") . "\";");
}
elseif($page == 'htpasswds')
{
if($action == '')
{
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_extras::htpasswds");
$fields = array(
'username' => $lng['login']['username'],
'path' => $lng['panel']['path']
);
$paging = new paging($userinfo, $db, TABLE_PANEL_HTPASSWDS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
$result = $db->query("SELECT `id`, `username`, `path` FROM `" . TABLE_PANEL_HTPASSWDS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' " . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
$paging->setEntries($db->num_rows($result));
$sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$i = 0;
$count = 0;
$htpasswds = '';
if ($page == 'overview' || $page == 'htpasswds') { while($row = $db->fetch_array($result))
// redirect if this customer sub-page is hidden via settings {
if (Settings::IsInList('panel.customer_hide_options', 'extras.directoryprotection')) { if($paging->checkDisplay($i))
Response::redirectTo('customer_index.php'); {
if(strpos($row['path'], $userinfo['documentroot']) === 0)
{
$row['path'] = substr($row['path'], strlen($userinfo['documentroot']));
}
$row = htmlentities_array($row);
eval("\$htpasswds.=\"" . getTemplate("extras/htpasswds_htpasswd") . "\";");
$count++;
}
$i++;
}
eval("echo \"" . getTemplate("extras/htpasswds") . "\";");
} }
elseif($action == 'delete'
&& $id != 0)
{
$result = $db->query_first("SELECT `id`, `customerid`, `username`, `path` FROM `" . TABLE_PANEL_HTPASSWDS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'");
if ($action == '') { if(isset($result['username'])
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_extras::htpasswds"); && $result['username'] != '')
$fields = [ {
'username' => lng('login.username'), if(isset($_POST['send'])
'path' => lng('panel.path') && $_POST['send'] == 'send')
]; {
try { $db->query("DELETE FROM `" . TABLE_PANEL_HTPASSWDS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='$id'");
$htpasswd_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.htpasswd.php'; $log->logAction(USR_ACTION, LOG_INFO, "deleted htpasswd for '" . $result['username'] . " (" . $result['path'] . ")'");
$collection = (new Collection(DirProtections::class, $userinfo)) inserttask('1');
->withPagination($htpasswd_list_data['htpasswd_list']['columns'], $htpasswd_list_data['htpasswd_list']['default_sorting']); redirectTo($filename, Array('page' => $page, 's' => $s));
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
UI::view('user/table.html.twig', [
'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) {
try {
$json_result = DirProtections::getLocal($userinfo, [
'id' => $id
])->get();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
if (isset($result['username']) && $result['username'] != '') {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
try {
DirProtections::getLocal($userinfo, $_POST)->delete();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
Response::redirectTo($filename, [
'page' => $page
]);
} else {
if (strpos($result['path'], $userinfo['documentroot']) === 0) {
$result['path'] = str_replace($userinfo['documentroot'], "/", $result['path']);
}
HTML::askYesNo('extras_reallydelete', $filename, [
'id' => $id,
'page' => $page,
'action' => $action
], $result['username'] . ' (' . $result['path'] . ')');
} }
} else
} elseif ($action == 'add') { {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if(strpos($result['path'], $userinfo['documentroot']) === 0)
try { {
DirProtections::getLocal($userinfo, $_POST)->add(); $result['path'] = substr($result['path'], strlen($userinfo['documentroot']));
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
Response::redirectTo($filename, [
'page' => $page
]);
} else {
$pathSelect = FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']);
$htpasswd_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htpasswd_add.php';
UI::view('user/form.html.twig', [
'formaction' => $linker->getLink(['section' => 'extras']),
'formdata' => $htpasswd_add_data['htpasswd_add']
]);
}
} elseif ($action == 'edit' && $id != 0) {
try {
$json_result = DirProtections::getLocal($userinfo, [
'id' => $id
])->get();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
if (isset($result['username']) && $result['username'] != '') {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
try {
DirProtections::getLocal($userinfo, $_POST)->update();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
} }
Response::redirectTo($filename, [
'page' => $page
]);
} else {
if (strpos($result['path'], $userinfo['documentroot']) === 0) {
$result['path'] = str_replace($userinfo['documentroot'], "/", $result['path']);
}
$result = PhpHelper::htmlentitiesArray($result);
$htpasswd_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htpasswd_edit.php'; ask_yesno('extras_reallydelete', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $result['username'] . ' (' . $result['path'] . ')');
UI::view('user/form.html.twig', [
'formaction' => $linker->getLink(['section' => 'extras', 'id' => $id]),
'formdata' => $htpasswd_edit_data['htpasswd_edit'],
'editid' => $id
]);
} }
} }
} }
} elseif ($page == 'htaccess') { elseif($action == 'add')
// redirect if this customer sub-page is hidden via settings {
if (Settings::IsInList('panel.customer_hide_options', 'extras.pathoptions')) { if(isset($_POST['send'])
Response::redirectTo('customer_index.php'); && $_POST['send'] == 'send')
} {
$path = makeCorrectDir(validate($_POST['path'], 'path'));
$userpath = $path;
$path = makeCorrectDir($userinfo['documentroot'] . '/' . $path);
$username = validate($_POST['username'], 'username', '/^[a-zA-Z0-9][a-zA-Z0-9\-_]+\$?$/');
validate($_POST['directory_password'], 'password');
$username_path_check = $db->query_first("SELECT `id`, `username`, `path` FROM `" . TABLE_PANEL_HTPASSWDS . "` WHERE `username`='" . $db->escape($username) . "' AND `path`='" . $db->escape($path) . "' AND `customerid`='" . (int)$userinfo['customerid'] . "'");
if ($action == '') { if(CRYPT_STD_DES == 1)
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_extras::htaccess"); {
$saltfordescrypt = substr(md5(uniqid(microtime(), 1)), 4, 2);
$password = crypt($_POST['directory_password'], $saltfordescrypt);
}
else
{
$password = crypt($_POST['directory_password']);
}
$cperlenabled = Customer::customerHasPerlEnabled($userinfo['customerid']); if(!$_POST['path'])
{
standard_error('invalidpath');
}
try { if($username == '')
$htaccess_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.htaccess.php'; {
$collection = (new Collection(DirOptions::class, $userinfo)) standard_error(array('stringisempty', 'myloginname'));
->withPagination($htaccess_list_data['htaccess_list']['columns'], $htaccess_list_data['htaccess_list']['default_sorting']); }
} catch (Exception $e) { elseif($username_path_check['username'] == $username
Response::dynamicError($e->getMessage()); && $username_path_check['path'] == $path)
} {
standard_error('userpathcombinationdupe');
UI::view('user/table.html.twig', [ }
'listing' => Listing::format($collection, $htaccess_list_data, 'htaccess_list'), elseif($_POST['directory_password'] == '')
'actions_links' => [ {
[ standard_error(array('stringisempty', 'mypassword'));
'href' => $linker->getLink(['section' => 'extras', 'page' => 'htaccess', 'action' => 'add']), }
'label' => lng('extras.pathoptions_add') elseif($path == '')
] {
], standard_error('patherror');
'entity_info' => lng('extras.description') }
]); else
} elseif ($action == 'delete' && $id != 0) { {
try { $db->query("INSERT INTO `" . TABLE_PANEL_HTPASSWDS . "` (`customerid`, `username`, `password`, `path`) VALUES ('" . (int)$userinfo['customerid'] . "', '" . $db->escape($username) . "', '" . $db->escape($password) . "', '" . $db->escape($path) . "')");
$json_result = DirOptions::getLocal($userinfo, [ $log->logAction(USR_ACTION, LOG_INFO, "added htpasswd for '" . $username . " (" . $path . ")'");
'id' => $id inserttask('1');
])->get(); redirectTo($filename, Array('page' => $page, 's' => $s));
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
if (isset($result['customerid']) && $result['customerid'] != '' && $result['customerid'] == $userinfo['customerid']) {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
try {
DirOptions::getLocal($userinfo, $_POST)->delete();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
Response::redirectTo($filename, [
'page' => $page
]);
} else {
HTML::askYesNo('extras_reallydelete_pathoptions', $filename, [
'id' => $id,
'page' => $page,
'action' => $action
], str_replace($userinfo['documentroot'], '/', $result['path']));
} }
} }
} elseif ($action == 'add') { else
if (isset($_POST['send']) && $_POST['send'] == 'send') { {
try { $pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $settings['panel']['pathedit']);
DirOptions::getLocal($userinfo, $_POST)->add(); eval("echo \"" . getTemplate("extras/htpasswds_add") . "\";");
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
Response::redirectTo($filename, [
'page' => $page
]);
} else {
$pathSelect = FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']);
$cperlenabled = Customer::customerHasPerlEnabled($userinfo['customerid']);
$htaccess_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htaccess_add.php';
UI::view('user/form.html.twig', [
'formaction' => $linker->getLink(['section' => 'extras']),
'formdata' => $htaccess_add_data['htaccess_add']
]);
}
} elseif (($action == 'edit') && ($id != 0)) {
try {
$json_result = DirOptions::getLocal($userinfo, [
'id' => $id
])->get();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
if ((isset($result['customerid'])) && ($result['customerid'] != '') && ($result['customerid'] == $userinfo['customerid'])) {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
try {
DirOptions::getLocal($userinfo, $_POST)->update();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
Response::redirectTo($filename, [
'page' => $page
]);
} else {
if (strpos($result['path'], $userinfo['documentroot']) === 0) {
$result['path'] = str_replace($userinfo['documentroot'], "/", $result['path']);
}
$cperlenabled = Customer::customerHasPerlEnabled($userinfo['customerid']);
$result = PhpHelper::htmlentitiesArray($result);
$htaccess_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htaccess_edit.php';
UI::view('user/form.html.twig', [
'formaction' => $linker->getLink(['section' => 'extras', 'id' => $id]),
'formdata' => $htaccess_edit_data['htaccess_edit'],
'editid' => $id
]);
}
} }
} }
} elseif ($page == 'backup') { elseif($action == 'edit'
// redirect if this customer sub-page is hidden via settings && $id != 0)
if (Settings::IsInList('panel.customer_hide_options', 'extras.backup')) { {
Response::redirectTo('customer_index.php'); $result = $db->query_first("SELECT `id`, `username`, `path` FROM `" . TABLE_PANEL_HTPASSWDS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'");
}
if (Settings::Get('system.backupenabled') == 1) { if(isset($result['username'])
if ($action == 'abort') { && $result['username'] != '')
if (isset($_POST['send']) && $_POST['send'] == 'send') { {
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "customer_extras::backup - aborted scheduled backupjob"); if(isset($_POST['send'])
try { && $_POST['send'] == 'send')
CustomerBackups::getLocal($userinfo, $_POST)->delete(); {
} catch (Exception $e) { validate($_POST['directory_password'], 'password');
Response::dynamicError($e->getMessage());
if(CRYPT_STD_DES == 1)
{
$saltfordescrypt = substr(md5(uniqid(microtime(), 1)), 4, 2);
$password = crypt($_POST['directory_password'], $saltfordescrypt);
} }
Response::redirectTo($filename, [ else
'page' => $page, {
'action' => '' $password = crypt($_POST['directory_password']);
]);
} else {
HTML::askYesNo('extras_reallydelete_backup', $filename, [
'backup_job_entry' => $id,
'section' => 'extras',
'page' => $page,
'action' => $action
]);
}
} elseif ($action == '') {
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_extras::backup");
// check whether there is a backup-job for this customer
try {
$backup_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.backups.php';
$collection = (new Collection(CustomerBackups::class, $userinfo));
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
if (isset($_POST['send']) && $_POST['send'] == 'send') {
try {
CustomerBackups::getLocal($userinfo, $_POST)->add();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
} }
Response::standardSuccess('backupscheduled');
} 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($_POST['directory_password'] == '')
'formaction' => $linker->getLink(['section' => 'extras']), {
'formdata' => $backup_data['backup'], standard_error(array('stringisempty', 'mypassword'));
'tabledata' => Listing::format($collection, $backup_list_data, 'backup_list'), }
]); else
{
$db->query("UPDATE `" . TABLE_PANEL_HTPASSWDS . "` SET `password`='" . $db->escape($password) . "' WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'");
$log->logAction(USR_ACTION, LOG_INFO, "edited htpasswd for '" . $result['username'] . " (" . $result['path'] . ")'");
inserttask('1');
redirectTo($filename, Array('page' => $page, 's' => $s));
}
}
else
{
if(strpos($result['path'], $userinfo['documentroot']) === 0)
{
$result['path'] = substr($result['path'], strlen($userinfo['documentroot']));
}
$result = htmlentities_array($result);
eval("echo \"" . getTemplate("extras/htpasswds_edit") . "\";");
} }
} }
} else {
Response::standardError('backupfunctionnotenabled');
} }
} }
elseif($page == 'htaccess')
{
if($action == '')
{
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_extras::htaccess");
$fields = array(
'path' => $lng['panel']['path'],
'options_indexes' => $lng['extras']['view_directory'],
'error404path' => $lng['extras']['error404path'],
'error403path' => $lng['extras']['error403path'],
'error500path' => $lng['extras']['error500path']
);
$paging = new paging($userinfo, $db, TABLE_PANEL_HTACCESS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
$result = $db->query("SELECT `id`, `path`, `options_indexes`, `error404path`, `error403path`, `error500path` FROM `" . TABLE_PANEL_HTACCESS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' " . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
$paging->setEntries($db->num_rows($result));
$sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$i = 0;
$count = 0;
$htaccess = '';
while($row = $db->fetch_array($result))
{
if($paging->checkDisplay($i))
{
if(strpos($row['path'], $userinfo['documentroot']) === 0)
{
$row['path'] = substr($row['path'], strlen($userinfo['documentroot']));
}
$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 = htmlentities_array($row);
eval("\$htaccess.=\"" . getTemplate("extras/htaccess_htaccess") . "\";");
$count++;
}
$i++;
}
eval("echo \"" . getTemplate("extras/htaccess") . "\";");
}
elseif($action == 'delete'
&& $id != 0)
{
$result = $db->query_first("SELECT * FROM `" . TABLE_PANEL_HTACCESS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'");
if(isset($result['customerid'])
&& $result['customerid'] != ''
&& $result['customerid'] == $userinfo['customerid'])
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$db->query("DELETE FROM `" . TABLE_PANEL_HTACCESS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'");
$log->logAction(USR_ACTION, LOG_INFO, "deleted htaccess for '" . str_replace($userinfo['documentroot'], '', $result['path']) . "'");
inserttask('1');
redirectTo($filename, Array('page' => $page, 's' => $s));
}
else
{
ask_yesno('extras_reallydelete_pathoptions', $filename, array('id' => $id, 'page' => $page, 'action' => $action), str_replace($userinfo['documentroot'], '', $result['path']));
}
}
}
elseif($action == 'add')
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$path = makeCorrectDir(validate($_POST['path'], 'path'));
$userpath = $path;
$path = makeCorrectDir($userinfo['documentroot'] . '/' . $path);
$path_dupe_check = $db->query_first("SELECT `id`, `path` FROM `" . TABLE_PANEL_HTACCESS . "` WHERE `path`='" . $db->escape($path) . "' AND `customerid`='" . (int)$userinfo['customerid'] . "'");
if(!$_POST['path'])
{
standard_error('invalidpath');
}
if(($_POST['error404path'] === '')
|| (validateUrl($idna_convert->encode($_POST['error404path']))))
{
$error404path = $_POST['error404path'];
}
else
{
standard_error('mustbeurl');
}
if(($_POST['error403path'] === '')
|| (validateUrl($idna_convert->encode($_POST['error403path']))))
{
$error403path = $_POST['error403path'];
}
else
{
standard_error('mustbeurl');
}
if(($_POST['error500path'] === '')
|| (validateUrl($idna_convert->encode($_POST['error500path']))))
{
$error500path = $_POST['error500path'];
}
else
{
standard_error('mustbeurl');
}
if($path_dupe_check['path'] == $path)
{
standard_error('errordocpathdupe', $userpath);
}
elseif($path == '')
{
standard_error('patherror');
}
else
{
$db->query('INSERT INTO `' . TABLE_PANEL_HTACCESS . '` (`customerid`, `path`, `options_indexes`, `error404path`, `error403path`, `error500path` ) VALUES ("' . (int)$userinfo['customerid'] . '", "' . $db->escape($path) . '", "' . $db->escape($_POST['options_indexes'] == '1' ? '1' : '0') . '", "' . $db->escape($error404path) . '", "' . $db->escape($error403path) . '", "' . $db->escape($error500path) . '" )');
$log->logAction(USR_ACTION, LOG_INFO, "added htaccess for '" . $path . "'");
inserttask('1');
redirectTo($filename, Array('page' => $page, 's' => $s));
}
}
else
{
$pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $settings['panel']['pathedit']);
$options_indexes = makeyesno('options_indexes', '1', '0', '1');
eval("echo \"" . getTemplate("extras/htaccess_add") . "\";");
}
}
elseif(($action == 'edit')
&& ($id != 0))
{
$result = $db->query_first('SELECT * FROM `' . TABLE_PANEL_HTACCESS . '` WHERE `customerid` = "' . (int)$userinfo['customerid'] . '" AND `id` = "' . (int)$id . '"');
if((isset($result['customerid']))
&& ($result['customerid'] != '')
&& ($result['customerid'] == $userinfo['customerid']))
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$option_indexes = intval($_POST['options_indexes']);
if($option_indexes != '1')
{
$option_indexes = '0';
}
if(($_POST['error404path'] === '')
|| (validateUrl($idna_convert->encode($_POST['error404path']))))
{
$error404path = $_POST['error404path'];
}
else
{
standard_error('mustbeurl');
}
if(($_POST['error403path'] === '')
|| (validateUrl($idna_convert->encode($_POST['error403path']))))
{
$error403path = $_POST['error403path'];
}
else
{
standard_error('mustbeurl');
}
if(($_POST['error500path'] === '')
|| (validateUrl($idna_convert->encode($_POST['error500path']))))
{
$error500path = $_POST['error500path'];
}
else
{
standard_error('mustbeurl');
}
if(($option_indexes != $result['options_indexes'])
|| ($error404path != $result['error404path'])
|| ($error403path != $result['error403path'])
|| ($error500path != $result['error500path']))
{
inserttask('1');
$db->query('UPDATE `' . TABLE_PANEL_HTACCESS . '` SET `options_indexes` = "' . $db->escape($option_indexes) . '", `error404path` = "' . $db->escape($error404path) . '", `error403path` = "' . $db->escape($error403path) . '", `error500path` = "' . $db->escape($error500path) . '" WHERE `customerid` = "' . (int)$userinfo['customerid'] . '" AND `id` = "' . (int)$id . '"');
$log->logAction(USR_ACTION, LOG_INFO, "edited htaccess for '" . str_replace($userinfo['documentroot'], '', $result['path']) . "'");
}
redirectTo($filename, Array('page' => $page, 's' => $s));
}
else
{
if(strpos($result['path'], $userinfo['documentroot']) === 0)
{
$result['path'] = substr($result['path'], strlen($userinfo['documentroot']));
}
$result['error404path'] = $result['error404path'];
$result['error403path'] = $result['error403path'];
$result['error500path'] = $result['error500path'];
$options_indexes = makeyesno('options_indexes', '1', '0', $result['options_indexes']);
$result = htmlentities_array($result);
eval("echo \"" . getTemplate("extras/htaccess_edit") . "\";");
}
}
}
}
?>

View File

@@ -2,204 +2,244 @@
/** /**
* 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 * @version $Id$
* 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 = 'customer'; define('AREA', 'customer');
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\Ftps as Ftps; /**
use Froxlor\Database\Database; * Include our init.php, which manages Sessions, Language etc.
use Froxlor\FileDir; */
use Froxlor\FroxlorLogger;
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;
use Froxlor\CurrentUser;
// redirect if this customer page is hidden via settings require ("./lib/init.php");
if (Settings::IsInList('panel.customer_hide_options', 'ftp') || $userinfo['ftps'] == 0) {
Response::redirectTo('customer_index.php'); if(isset($_POST['id']))
{
$id = intval($_POST['id']);
}
elseif(isset($_GET['id']))
{
$id = intval($_GET['id']);
} }
$id = (int)Request::any('id', 0); if($page == 'overview')
{
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_ftp");
eval("echo \"" . getTemplate("ftp/ftp") . "\";");
}
elseif($page == 'accounts')
{
if($action == '')
{
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_ftp::accounts");
$fields = array(
'username' => $lng['login']['username'],
'homedir' => $lng['panel']['path']
);
$paging = new paging($userinfo, $db, TABLE_FTP_USERS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
$result = $db->query("SELECT `id`, `username`, `homedir` FROM `" . TABLE_FTP_USERS . "` WHERE `customerid`='" . $userinfo['customerid'] . "' " . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
$paging->setEntries($db->num_rows($result));
$sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$i = 0;
$count = 0;
$accounts = '';
if ($page == 'overview' || $page == 'accounts') { while($row = $db->fetch_array($result))
if ($action == '') { {
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_ftp::accounts"); if($paging->checkDisplay($i))
try { {
$ftp_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.ftps.php'; if(strpos($row['homedir'], $userinfo['documentroot']) === 0)
$collection = (new Collection(Ftps::class, $userinfo)) {
->withPagination($ftp_list_data['ftp_list']['columns'], $ftp_list_data['ftp_list']['default_sorting']); $row['documentroot'] = substr($row['homedir'], strlen($userinfo['documentroot']));
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
$actions_links = false;
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) {
try {
$json_result = Ftps::getLocal($userinfo, [
'id' => $id
])->get();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
if (isset($result['username']) && $result['username'] != $userinfo['loginname']) {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
try {
Ftps::getLocal($userinfo, $_POST)->delete();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
} }
Response::redirectTo($filename, [ else
'page' => $page {
]); $row['documentroot'] = $row['homedir'];
} else { }
HTML::askYesNoWithCheckbox('ftp_reallydelete', 'admin_customer_alsoremoveftphomedir', $filename, [
'id' => $id, $row['documentroot'] = makeCorrectDir($row['documentroot']);
'page' => $page,
'action' => $action $row = htmlentities_array($row);
], $result['username']); eval("\$accounts.=\"" . getTemplate("ftp/accounts_account") . "\";");
$count++;
} }
} else {
Response::standardError('ftp_cantdeletemainaccount'); $i++;
} }
} elseif ($action == 'add') {
if ($userinfo['ftps_used'] < $userinfo['ftps'] || $userinfo['ftps'] == '-1') { $ftps_count = $db->num_rows($result);
if (isset($_POST['send']) && $_POST['send'] == 'send') { eval("echo \"" . getTemplate("ftp/accounts") . "\";");
try { }
Ftps::getLocal($userinfo, $_POST)->add(); elseif($action == 'delete'
} catch (Exception $e) { && $id != 0)
Response::dynamicError($e->getMessage()); {
$result = $db->query_first("SELECT `id`, `username`, `homedir`, `up_count`, `up_bytes`, `down_count`, `down_bytes` FROM `" . TABLE_FTP_USERS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'");
if(isset($result['username'])
&& $result['username'] != $userinfo['loginname'])
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$db->query("UPDATE `" . TABLE_FTP_USERS . "` SET `up_count`=`up_count`+'" . (int)$result['up_count'] . "', `up_bytes`=`up_bytes`+'" . (int)$result['up_bytes'] . "', `down_count`=`down_count`+'" . (int)$result['down_count'] . "', `down_bytes`=`down_bytes`+'" . (int)$result['down_bytes'] . "' WHERE `username`='" . $db->escape($userinfo['loginname']) . "'");
$db->query("DELETE FROM `" . TABLE_FTP_USERS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'");
$log->logAction(USR_ACTION, LOG_INFO, "deleted ftp-account '" . $result['username'] . "'");
$db->query("UPDATE `" . TABLE_FTP_GROUPS . "` SET `members`=REPLACE(`members`,'," . $db->escape($result['username']) . "','') WHERE `customerid`='" . (int)$userinfo['customerid'] . "'");
// $db->query("DELETE FROM `".TABLE_FTP_GROUPS."` WHERE `customerid`='".$userinfo['customerid']."' AND `id`='$id'");
if($userinfo['ftps_used'] == '1')
{
$resetaccnumber = " , `ftp_lastaccountnumber`='0'";
} }
Response::redirectTo($filename, [ else
'page' => $page {
]); $resetaccnumber = '';
} else {
$pathSelect = FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], '/');
if (Settings::Get('customer.ftpatdomain') == '1') {
$domainlist = [];
$result_domains_stmt = Database::prepare("SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "`
WHERE `customerid`= :customerid");
Database::pexecute($result_domains_stmt, [
"customerid" => $userinfo['customerid']
]);
while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) {
$domainlist[$row_domain['domain']] = $idna_convert->decode($row_domain['domain']);
}
sort($domainlist);
} }
if (Settings::Get('system.allow_customer_shell') == '1') { $result = $db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `ftps_used`=`ftps_used`-1 $resetaccnumber WHERE `customerid`='" . (int)$userinfo['customerid'] . "'");
$shells['/bin/false'] = "/bin/false"; redirectTo($filename, Array('page' => $page, 's' => $s));
$shells_avail = Settings::Get('system.available_shells'); }
if (!empty($shells_avail)) { else
$shells_avail_arr = explode(",", $shells_avail); {
$shells_avail_arr = array_map("trim", $shells_avail_arr); ask_yesno('ftp_reallydelete', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $result['username']);
foreach ($shells_avail_arr as $shell) {
$shells[$shell] = $shell;
}
}
}
$ftp_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/ftp/formfield.ftp_add.php';
UI::view('user/form.html.twig', [
'formaction' => $linker->getLink(['section' => 'ftp']),
'formdata' => $ftp_add_data['ftp_add']
]);
} }
} }
} elseif ($action == 'edit' && $id != 0) { else
try { {
$json_result = Ftps::getLocal($userinfo, [ standard_error('ftp_cantdeletemainaccount');
'id' => $id
])->get();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
} }
$result = json_decode($json_result, true)['data']; }
elseif($action == 'add')
{
if($userinfo['ftps_used'] < $userinfo['ftps']
|| $userinfo['ftps'] == '-1')
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$path = validate($_POST['path'], 'path');
$password = validate($_POST['ftp_password'], 'password');
if (isset($result['username']) && $result['username'] != '') { if($settings['customer']['ftpatdomain'] == '1')
if (isset($_POST['send']) && $_POST['send'] == 'send') { {
try { $ftpusername = validate($_POST['ftp_username'], 'username', '/^[a-zA-Z0-9][a-zA-Z0-9\-_]+\$?$/');
Ftps::getLocal($userinfo, $_POST)->update(); if($ftpusername == '')
} catch (Exception $e) { {
Response::dynamicError($e->getMessage()); standard_error(array('stringisempty', 'username'));
}
$ftpdomain = $idna_convert->encode(validate($_POST['ftp_domain'], 'domain'));
$ftpdomain_check = $db->query_first("SELECT `id`, `domain`, `customerid` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `domain`='" . $db->escape($ftpdomain) . "' AND `customerid`='" . (int)$userinfo['customerid'] . "'");
if($ftpdomain_check['domain'] != $ftpdomain)
{
standard_error('maindomainnonexist', $domain);
}
$username = $ftpusername . "@" . $ftpdomain;
} }
Response::redirectTo($filename, [ else
'page' => $page {
]); $username = $userinfo['loginname'] . $settings['customer']['ftpprefix'] . (intval($userinfo['ftp_lastaccountnumber']) + 1);
} else {
if (strpos($result['homedir'], $userinfo['documentroot']) === 0) {
$homedir = str_replace($userinfo['documentroot'], "/", $result['homedir']);
} else {
$homedir = $result['homedir'];
} }
$homedir = FileDir::makeCorrectDir($homedir);
$username_check = $db->query_first('SELECT * FROM `' . TABLE_FTP_USERS .'` WHERE `username` = \'' . $db->escape($username) . '\'');
if(!empty($username_check) && $username_check['username'] = $username)
{
standard_error('usernamealreadyexists', $username);
}
elseif($password == '')
{
standard_error(array('stringisempty', 'mypassword'));
}
elseif($path == '')
{
standard_error('patherror');
}
else
{
$userpath = makeCorrectDir($path);
$path = makeCorrectDir($userinfo['documentroot'] . '/' . $path);
$db->query("INSERT INTO `" . TABLE_FTP_USERS . "` (`customerid`, `username`, `password`, `homedir`, `login_enabled`, `uid`, `gid`) VALUES ('" . (int)$userinfo['customerid'] . "', '" . $db->escape($username) . "', ENCRYPT('" . $db->escape($password) . "'), '" . $db->escape($path) . "', 'y', '" . (int)$userinfo['guid'] . "', '" . (int)$userinfo['guid'] . "')");
$db->query("UPDATE `" . TABLE_FTP_GROUPS . "` SET `members`=CONCAT_WS(',',`members`,'" . $db->escape($username) . "') WHERE `customerid`='" . $userinfo['customerid'] . "' AND `gid`='" . (int)$userinfo['guid'] . "'");
$pathSelect = FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $homedir); // $db->query("INSERT INTO `".TABLE_FTP_GROUPS."` (`customerid`, `groupname`, `gid`, `members`) VALUES ('".$userinfo['customerid']."', '$username', '$uid', '$username')");
if (Settings::Get('system.allow_customer_shell') == '1') { $db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `ftps_used`=`ftps_used`+1, `ftp_lastaccountnumber`=`ftp_lastaccountnumber`+1 WHERE `customerid`='" . (int)$userinfo['customerid'] . "'");
$shells['/bin/false'] = "/bin/false";
$shells_avail = Settings::Get('system.available_shells'); // $db->query("UPDATE `".TABLE_PANEL_SETTINGS."` SET `value`='$uid' WHERE settinggroup='ftp' AND varname='lastguid'");
if (!empty($shells_avail)) {
$shells_avail_arr = explode(",", $shells_avail); $log->logAction(USR_ACTION, LOG_INFO, "added ftp-account '" . $username . " (" . $path . ")'");
$shells_avail_arr = array_map("trim", $shells_avail_arr); inserttask(5);
foreach ($shells_avail_arr as $shell) { redirectTo($filename, Array('page' => $page, 's' => $s));
$shells[$shell] = $shell; }
} }
else
{
$pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $settings['panel']['pathedit']);
if($settings['customer']['ftpatdomain'] == '1')
{
$domains = '';
$result_domains = $db->query("SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "'");
while($row_domain = $db->fetch_array($result_domains))
{
$domains.= makeoption($idna_convert->decode($row_domain['domain']), $row_domain['domain']);
} }
} }
$ftp_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/ftp/formfield.ftp_edit.php'; eval("echo \"" . getTemplate("ftp/accounts_add") . "\";");
}
}
}
elseif($action == 'edit'
&& $id != 0)
{
$result = $db->query_first("SELECT `id`, `username`, `homedir` FROM `" . TABLE_FTP_USERS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'");
UI::view('user/form.html.twig', [ if(isset($result['username'])
'formaction' => $linker->getLink(['section' => 'ftp', 'id' => $id]), && $result['username'] != '')
'formdata' => $ftp_edit_data['ftp_edit'], {
'editid' => $id if(isset($_POST['send'])
]); && $_POST['send'] == 'send')
{
$password = validate($_POST['ftp_password'], 'password');
if($password == '')
{
standard_error(array('stringisempty', 'mypassword'));
exit;
}
else
{
$db->query("UPDATE `" . TABLE_FTP_USERS . "` SET `password`=ENCRYPT('" . $db->escape($password) . "') WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'");
$log->logAction(USR_ACTION, LOG_INFO, "edited ftp-account '" . $result['username'] . "'");
redirectTo($filename, Array('page' => $page, 's' => $s));
}
}
else
{
eval("echo \"" . getTemplate("ftp/accounts_edit") . "\";");
} }
} }
} }
} }
?>

View File

@@ -2,271 +2,183 @@
/** /**
* 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 * @version $Id$
* 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 = 'customer'; define('AREA', 'customer');
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\Customers as Customers; /**
use Froxlor\CurrentUser; * Include our init.php, which manages Sessions, Language etc.
use Froxlor\Database\Database; */
use Froxlor\Froxlor;
use Froxlor\FroxlorLogger;
use Froxlor\Settings;
use Froxlor\System\Crypt;
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') { require ("./lib/init.php");
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, 'logged out');
unset($_SESSION['userinfo']); if($action == 'logout')
CurrentUser::setData(); {
session_destroy(); $log->logAction(USR_ACTION, LOG_NOTICE, "logged out");
Response::redirectTo('index.php'); if($settings['session']['allow_multiple_login'] == '1')
} elseif ($action == 'suback') { {
if (is_array(CurrentUser::getField('switched_user'))) { $db->query("DELETE FROM `" . TABLE_PANEL_SESSIONS . "` WHERE `userid` = '" . (int)$userinfo['customerid'] . "' AND `adminsession` = '0' AND `hash` = '" . $s . "'");
$result = CurrentUser::getData();
$result = $result['switched_user'];
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 {
Response::dynamicError("Cannot change back - You've never switched to another user :-)");
} }
else
{
$db->query("DELETE FROM `" . TABLE_PANEL_SESSIONS . "` WHERE `userid` = '" . (int)$userinfo['customerid'] . "' AND `adminsession` = '0'");
}
redirectTo('index.php');
exit;
} }
if ($page == 'overview') { if($page == 'overview')
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_index"); {
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_index");
$domains = '';
$result = $db->query("SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `parentdomainid`='0' AND `id` <> '" . (int)$userinfo['standardsubdomain'] . "' ");
$domainArray = array();
$domain_stmt = Database::prepare("SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "` while($row = $db->fetch_array($result))
WHERE `customerid` = :customerid {
AND `parentdomainid` = '0'
AND `id` <> :standardsubdomain
");
Database::pexecute($domain_stmt, [
"customerid" => $userinfo['customerid'],
"standardsubdomain" => $userinfo['standardsubdomain']
]);
$domainArray = [];
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(', ', $domainArray);
// standard-subdomain
$stdsubdomain = '';
if ($userinfo['standardsubdomain'] != '0') {
$std_domain_stmt = Database::prepare("
SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "`
WHERE `customerid` = :customerid
AND `id` = :standardsubdomain
");
$std_domain = Database::pexecute_first($std_domain_stmt, [
"customerid" => $userinfo['customerid'],
"standardsubdomain" => $userinfo['standardsubdomain']
]);
$stdsubdomain = $std_domain['domain'];
}
$userinfo['email'] = $idna_convert->decode($userinfo['email']); $userinfo['email'] = $idna_convert->decode($userinfo['email']);
$yesterday = time() - (60 * 60 * 24); $yesterday = time() - (60 * 60 * 24);
$month = date('M Y', $yesterday); $month = date('M Y', $yesterday);
// get disk-space usages for web, mysql and mail /* $traffic=$db->query_first("SELECT SUM(http) AS http_sum, SUM(ftp_up) AS ftp_up_sum, SUM(ftp_down) AS ftp_down_sum, SUM(mail) AS mail_sum FROM ".TABLE_PANEL_TRAFFIC." WHERE year='".date('Y')."' AND month='".date('m')."' AND day<='".date('d')."' AND customerid='".$userinfo['customerid']."'");
$usages_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_DISKSPACE . "` WHERE `customerid` = :cid ORDER BY `stamp` DESC LIMIT 1"); $userinfo['traffic_used']=$traffic['http_sum']+$traffic['ftp_up_sum']+$traffic['ftp_down_sum']+$traffic['mail_sum'];*/
$usages = Database::pexecute_first($usages_stmt, [
'cid' => $userinfo['customerid']
]);
// get everything in bytes for the percentage calculation on the dashboard $userinfo['diskspace'] = round($userinfo['diskspace'] / 1024, $settings['panel']['decimal_places']);
$userinfo['diskspace_bytes'] = ($userinfo['diskspace'] > -1) ? $userinfo['diskspace'] * 1024 : -1; $userinfo['diskspace_used'] = round($userinfo['diskspace_used'] / 1024, $settings['panel']['decimal_places']);
$userinfo['traffic_bytes'] = ($userinfo['traffic'] > -1) ? $userinfo['traffic'] * 1024 : -1; $userinfo['traffic'] = round($userinfo['traffic'] / (1024 * 1024), $settings['panel']['decimal_places']);
$userinfo['traffic_bytes_used'] = $userinfo['traffic_used'] * 1024; $userinfo['traffic_used'] = round($userinfo['traffic_used'] / (1024 * 1024), $settings['panel']['decimal_places']);
$userinfo = str_replace_array('-1', $lng['customer']['unlimited'], $userinfo, 'diskspace traffic mysqls emails email_accounts email_forwarders email_quota ftps tickets subdomains aps_packages');
$opentickets = 0;
$opentickets = $db->query_first('SELECT COUNT(`id`) as `count` FROM `' . TABLE_PANEL_TICKETS . '`
WHERE `customerid` = "' . $userinfo['customerid'] . '"
AND `answerto` = "0"
AND (`status` = "0" OR `status` = "2")
AND `lastreplier`="1"');
$awaitingtickets = $opentickets['count'];
$awaitingtickets_text = '';
if ($usages) { if($opentickets > 0)
$userinfo['diskspace_bytes_used'] = $usages['webspace'] * 1024; {
$userinfo['total_bytes_used'] = ($usages['webspace'] + $usages['mail'] + $usages['mysql']) * 1024; $awaitingtickets_text = strtr($lng['ticket']['awaitingticketreply'], array('%s' => '<a href="customer_tickets.php?page=tickets&amp;s=' . $s . '">' . $opentickets['count'] . '</a>'));
} else {
$userinfo['diskspace_bytes_used'] = 0;
$userinfo['total_bytes_used'] = 0;
} }
UI::twig()->addGlobal('userinfo', $userinfo); eval("echo \"" . getTemplate("index/index") . "\";");
UI::view('user/index.html.twig', [
'domains' => $domainArray,
'stdsubdomain' => $stdsubdomain
]);
} 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')) {
Response::standardError('oldpasswordnotcorrect');
}
try {
$new_password = Crypt::validatePassword($_POST['new_password'], 'new password');
$new_password_confirm = Crypt::validatePassword($_POST['new_password_confirm'], 'new password confirm');
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
if ($old_password == '') {
Response::standardError([
'stringisempty',
'changepassword.old_password'
]);
} elseif ($new_password == '') {
Response::standardError([
'stringisempty',
'changepassword.new_password'
]);
} elseif ($new_password_confirm == '') {
Response::standardError([
'stringisempty',
'changepassword.new_password_confirm'
]);
} elseif ($new_password != $new_password_confirm) {
Response::standardError('newpasswordconfirmerror');
} else {
// Update user password
try {
Customers::getLocal($userinfo, [
'id' => $userinfo['customerid'],
'new_customer_password' => $new_password
])->update();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, 'changed password');
// Update ftp password
if (isset($_POST['change_main_ftp']) && $_POST['change_main_ftp'] == 'true') {
$cryptPassword = Crypt::makeCryptPassword($new_password);
$stmt = Database::prepare("UPDATE `" . TABLE_FTP_USERS . "`
SET `password` = :password
WHERE `customerid` = :customerid
AND `username` = :username");
$params = [
"password" => $cryptPassword,
"customerid" => $userinfo['customerid'],
"username" => $userinfo['loginname']
];
Database::pexecute($stmt, $params);
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, 'changed main ftp password');
}
// Update statistics password
if (isset($_POST['change_stats']) && $_POST['change_stats'] == 'true') {
$new_stats_password = Crypt::makeCryptPassword($new_password, true);
$stmt = Database::prepare("UPDATE `" . TABLE_PANEL_HTPASSWDS . "`
SET `password` = :password
WHERE `customerid` = :customerid
AND `username` = :username");
$params = [
"password" => $new_stats_password,
"customerid" => $userinfo['customerid'],
"username" => $userinfo['loginname']
];
Database::pexecute($stmt, $params);
Cronjob::inserttask(TaskId::REBUILD_VHOST);
}
Response::redirectTo($filename);
}
} else {
UI::view('user/change_password.html.twig');
}
} elseif ($page == 'change_language') {
$languages = Language::getLanguages();
if (isset($_POST['send']) && $_POST['send'] == 'send') {
$def_language = Validate::validate($_POST['def_language'], 'default language');
if (isset($languages[$def_language])) {
try {
Customers::getLocal($userinfo, [
'id' => $userinfo['customerid'],
'def_language' => $def_language
])->update();
CurrentUser::setField('language', $def_language);
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
}
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "changed default language to '" . $def_language . "'");
Response::redirectTo($filename);
} else {
$default_lang = Settings::Get('panel.standardlanguage');
if ($userinfo['def_language'] != '') {
$default_lang = $userinfo['def_language'];
}
UI::view('user/change_language.html.twig', [
'languages' => $languages,
'default_lang' => $default_lang
]);
}
} elseif ($page == 'change_theme') {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
$theme = Validate::validate($_POST['theme'], 'theme');
try {
Customers::getLocal($userinfo, [
'id' => $userinfo['customerid'],
'theme' => $theme
])->update();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "changed default theme to '" . $theme . "'");
Response::redirectTo($filename);
} else {
$default_theme = Settings::Get('panel.default_theme');
if ($userinfo['theme'] != '') {
$default_theme = $userinfo['theme'];
}
$themes_avail = UI::getThemes();
UI::view('user/change_theme.html.twig', [
'themes' => $themes_avail,
'default_theme' => $default_theme
]);
}
} elseif ($page == 'send_error_report' && Settings::Get('system.allow_error_report_customer') == '1') {
require_once __DIR__ . '/error_report.php';
} elseif ($page == 'apikeys' && Settings::Get('api.enabled') == 1) {
require_once __DIR__ . '/api_keys.php';
} elseif ($page == '2fa' && Settings::Get('2fa.enabled') == 1) {
require_once __DIR__ . '/2fa.php';
} }
elseif($page == 'change_password')
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$old_password = validate($_POST['old_password'], 'old password');
if(md5($old_password) != $userinfo['password'])
{
standard_error('oldpasswordnotcorrect');
exit;
}
$new_password = validate($_POST['new_password'], 'new password');
$new_password_confirm = validate($_POST['new_password_confirm'], 'new password confirm');
if($old_password == '')
{
standard_error(array('stringisempty', 'oldpassword'));
}
elseif($new_password == '')
{
standard_error(array('stringisempty', 'newpassword'));
}
elseif($new_password_confirm == '')
{
standard_error(array('stringisempty', 'newpasswordconfirm'));
}
elseif($new_password != $new_password_confirm)
{
standard_error('newpasswordconfirmerror');
}
else
{
$db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `password`='" . md5($new_password) . "' WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `password`='" . md5($old_password) . "'");
$log->logAction(USR_ACTION, LOG_NOTICE, 'changed password');
if(isset($_POST['change_main_ftp'])
&& $_POST['change_main_ftp'] == 'true')
{
$db->query("UPDATE `" . TABLE_FTP_USERS . "` SET `password`=ENCRYPT('" . $db->escape($new_password) . "') WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `username`='" . $db->escape($userinfo['loginname']) . "'");
$log->logAction(USR_ACTION, LOG_NOTICE, 'changed main ftp password');
}
if(isset($_POST['change_webalizer'])
&& $_POST['change_webalizer'] == 'true')
{
if(CRYPT_STD_DES == 1)
{
$saltfordescrypt = substr(md5(uniqid(microtime(), 1)), 4, 2);
$new_webalizer_password = crypt($new_password, $saltfordescrypt);
}
else
{
$new_webalizer_password = crypt($new_password);
}
$db->query("UPDATE `" . TABLE_PANEL_HTPASSWDS . "` SET `password`='" . $db->escape($new_webalizer_password) . "' WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `username`='" . $db->escape($userinfo['loginname']) . "'");
}
redirectTo($filename, Array('s' => $s));
}
}
else
{
eval("echo \"" . getTemplate("index/change_password") . "\";");
}
}
elseif($page == 'change_language')
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$def_language = validate($_POST['def_language'], 'default language');
if(isset($languages[$def_language]))
{
$db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `def_language`='" . $db->escape($def_language) . "' WHERE `customerid`='" . (int)$userinfo['customerid'] . "'");
$db->query("UPDATE `" . TABLE_PANEL_SESSIONS . "` SET `language`='" . $db->escape($def_language) . "' WHERE `hash`='" . $db->escape($s) . "'");
$log->logAction(USR_ACTION, LOG_NOTICE, "changed default language to '" . $def_language . "'");
}
redirectTo($filename, Array('s' => $s));
}
else
{
$language_options = '';
while(list($language_file, $language_name) = each($languages))
{
$language_options.= makeoption($language_name, $language_file, $userinfo['def_language'], true);
}
eval("echo \"" . getTemplate("index/change_language") . "\";");
}
}
?>

View File

@@ -1,54 +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 = 'customer';
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\SysLog;
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
if (Settings::IsInList('panel.customer_hide_options', 'extras.logger')) {
Response::redirectTo('customer_index.php');
}
if ($page == 'log') {
if ($action == '') {
try {
$syslog_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/tablelisting.syslog.php';
$collection = (new Collection(SysLog::class, $userinfo))
->withPagination($syslog_list_data['syslog_list']['columns'], $syslog_list_data['syslog_list']['default_sorting']);
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
UI::view('user/table.html.twig', [
'listing' => Listing::format($collection, $syslog_list_data, 'syslog_list')
]);
}
}

View File

@@ -2,197 +2,253 @@
/** /**
* 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 * @version $Id$
* 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 = 'customer'; define('AREA', 'customer');
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\Mysqls; /**
use Froxlor\Api\Commands\MysqlServer; * Include our init.php, which manages Sessions, Language etc.
use Froxlor\Database\Database; */
use Froxlor\FroxlorLogger;
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;
use Froxlor\CurrentUser;
// redirect if this customer page is hidden via settings or no resources given $need_root_db_sql_data = true;
if (Settings::IsInList('panel.customer_hide_options', 'mysql') || $userinfo['mysqls'] == 0) { require ("./lib/init.php");
Response::redirectTo('customer_index.php');
if(isset($_POST['id']))
{
$id = intval($_POST['id']);
}
elseif(isset($_GET['id']))
{
$id = intval($_GET['id']);
} }
// get sql-root access data if($page == 'overview')
Database::needRoot(true); {
Database::needSqlData(); $log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_mysql");
$sql_root = Database::getSqlData(); $lng['mysql']['description'] = str_replace('<SQL_HOST>', $sql['host'], $lng['mysql']['description']);
Database::needRoot(false); eval("echo \"" . getTemplate("mysql/mysql") . "\";");
}
elseif($page == 'mysqls')
{
if($action == '')
{
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_mysql::mysqls");
$fields = array(
'databasename' => $lng['mysql']['databasename'],
'description' => $lng['mysql']['databasedescription']
);
$paging = new paging($userinfo, $db, TABLE_PANEL_DATABASES, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
$result = $db->query("SELECT `id`, `databasename`, `description`, `dbserver` FROM `" . TABLE_PANEL_DATABASES . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' " . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
$paging->setEntries($db->num_rows($result));
$sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$i = 0;
$count = 0;
$mysqls = '';
$id = (int)Request::any('id'); while($row = $db->fetch_array($result))
{
if($paging->checkDisplay($i))
{
$row = htmlentities_array($row);
eval("\$mysqls.=\"" . getTemplate("mysql/mysqls_database") . "\";");
$count++;
}
if ($page == 'overview' || $page == 'mysqls') { $i++;
if ($action == '') {
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_mysql::mysqls");
$multiple_mysqlservers = count(json_decode($userinfo['allowed_mysqlserver'] ?? '[]', true)) > 1;
try {
$mysql_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.mysqls.php';
$collection = (new Collection(Mysqls::class, $userinfo))
->withPagination($mysql_list_data['mysql_list']['columns'], $mysql_list_data['mysql_list']['default_sorting']);
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
} }
$actions_links = false; $mysqls_count = $db->num_rows($result);
if (CurrentUser::canAddResource('mysqls')) { eval("echo \"" . getTemplate("mysql/mysqls") . "\";");
$actions_links = [ }
[ elseif($action == 'delete'
'href' => $linker->getLink(['section' => 'mysql', 'page' => 'mysqls', 'action' => 'add']), && $id != 0)
'label' => lng('mysql.database_create') {
] $result = $db->query_first('SELECT `id`, `databasename`, `dbserver` FROM `' . TABLE_PANEL_DATABASES . '` WHERE `customerid`="' . (int)$userinfo['customerid'] . '" AND `id`="' . (int)$id . '"');
];
}
UI::view('user/table.html.twig', [ if(isset($result['databasename'])
'listing' => Listing::format($collection, $mysql_list_data, 'mysql_list'), && $result['databasename'] != '')
'actions_links' => $actions_links, {
'entity_info' => lng('mysql.description') if(!isset($sql_root[$result['dbserver']]) || !is_array($sql_root[$result['dbserver']]))
]); {
} elseif ($action == 'delete' && $id != 0) {
try {
$json_result = Mysqls::getLocal($userinfo, [
'id' => $id
])->get();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
if (isset($result['databasename']) && $result['databasename'] != '') {
Database::needRoot(true, $result['dbserver']);
Database::needSqlData();
$sql_root = Database::getSqlData();
Database::needRoot(false);
if (!isset($sql_root[$result['dbserver']]) || !is_array($sql_root[$result['dbserver']])) {
$result['dbserver'] = 0; $result['dbserver'] = 0;
} }
if (isset($_POST['send']) && $_POST['send'] == 'send') { if(isset($_POST['send'])
try { && $_POST['send'] == 'send')
Mysqls::getLocal($userinfo, $_POST)->delete(); {
} catch (Exception $e) { // Begin root-session
Response::dynamicError($e->getMessage());
$db_root = new db($sql_root[$result['dbserver']]['host'], $sql_root[$result['dbserver']]['user'], $sql_root[$result['dbserver']]['password'], '');
unset($db_root->password);
foreach(array_map('trim', array_unique(explode(',', $settings['system']['mysql_access_host']))) as $mysql_access_host)
{
$db_root->query('REVOKE ALL PRIVILEGES ON * . * FROM `' . $db_root->escape($result['databasename']) . '`@`' . $db_root->escape($mysql_access_host) . '`');
$db_root->query('REVOKE ALL PRIVILEGES ON `' . str_replace('_', '\_', $db_root->escape($result['databasename'])) . '` . * FROM `' . $db_root->escape($result['databasename']) . '`@`' . $db_root->escape($mysql_access_host) . '`');
$db_root->query('DELETE FROM `mysql`.`user` WHERE `User` = "' . $db_root->escape($result['databasename']) . '" AND `Host` = "' . $db_root->escape($mysql_access_host) . '"');
} }
Response::redirectTo($filename, [
'page' => $page $db_root->query('DROP DATABASE IF EXISTS `' . $db_root->escape($result['databasename']) . '`');
]); $db_root->query('FLUSH PRIVILEGES');
} else { $db_root->close();
$dbnamedesc = $result['databasename'];
if (isset($result['description']) && $result['description'] != '') { // End root-session
$dbnamedesc .= ' (' . $result['description'] . ')';
$db->query('DELETE FROM `' . TABLE_PANEL_DATABASES . '` WHERE `customerid`="' . (int)$userinfo['customerid'] . '" AND `id`="' . (int)$id . '"');
if($userinfo['mysqls_used'] == '1')
{
$resetaccnumber = " , `mysql_lastaccountnumber`='0' ";
} }
HTML::askYesNo('mysql_reallydelete', $filename, [ else
'id' => $id, {
'page' => $page, $resetaccnumber = '';
'action' => $action }
], $dbnamedesc);
$result = $db->query('UPDATE `' . TABLE_PANEL_CUSTOMERS . '` SET `mysqls_used`=`mysqls_used`-1 ' . $resetaccnumber . 'WHERE `customerid`="' . (int)$userinfo['customerid'] . '"');
redirectTo($filename, Array('page' => $page, 's' => $s));
}
else
{
ask_yesno('mysql_reallydelete', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $result['databasename']);
} }
} }
} elseif ($action == 'add') { }
if ($userinfo['mysqls_used'] < $userinfo['mysqls'] || $userinfo['mysqls'] == '-1') { elseif($action == 'add')
if (isset($_POST['send']) && $_POST['send'] == 'send') { {
try { if($userinfo['mysqls_used'] < $userinfo['mysqls']
Mysqls::getLocal($userinfo, $_POST)->add(); || $userinfo['mysqls'] == '-1')
} catch (Exception $e) { {
Response::dynamicError($e->getMessage()); if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$password = validate($_POST['mysql_password'], 'password');
if($password == '')
{
standard_error(array('stringisempty', 'mypassword'));
} }
Response::redirectTo($filename, [ else
'page' => $page {
]); $username = $userinfo['loginname'] . $settings['customer']['mysqlprefix'] . (intval($userinfo['mysql_lastaccountnumber']) + 1);
} else {
$mysql_servers = []; if(count($sql_root) > 1)
try { {
$result_json = MysqlServer::getLocal($userinfo)->listing(); $dbserver = validate($_POST['mysql_server'], html_entity_decode($lng['mysql']['mysql_server']), '', '', 0);
$result_decoded = json_decode($result_json, true)['data']['list'];
foreach ($result_decoded as $dbserver => $dbdata) { if(!isset($sql_root[$dbserver]) || !is_array($sql_root[$dbserver]))
$mysql_servers[$dbserver] = $dbdata['caption']; {
$dbserver = 0;
}
} }
} catch (Exception $e) { else
/* just none */ {
$dbserver = 0;
}
// Begin root-session
$db_root = new db($sql_root[$dbserver]['host'], $sql_root[$dbserver]['user'], $sql_root[$dbserver]['password'], '');
unset($db_root->password);
$db_root->query('CREATE DATABASE `' . $db_root->escape($username) . '`');
$log->logAction(USR_ACTION, LOG_INFO, "created database '" . $username . "'");
foreach(array_map('trim', explode(',', $settings['system']['mysql_access_host'])) as $mysql_access_host)
{
$db_root->query('GRANT ALL PRIVILEGES ON `' . str_replace('_', '\_', $db_root->escape($username)) . '`.* TO `' . $db_root->escape($username) . '`@`' . $db_root->escape($mysql_access_host) . '` IDENTIFIED BY \'password\'');
$db_root->query('SET PASSWORD FOR `' . $db_root->escape($username) . '`@`' . $db_root->escape($mysql_access_host) . '` = PASSWORD(\'' . $db_root->escape($password) . '\')');
$log->logAction(USR_ACTION, LOG_NOTICE, "grant all privileges for '" . $username . "'@'" . $mysql_access_host . "'");
}
$db_root->query('FLUSH PRIVILEGES');
$db_root->close();
// End root-session
// Statement modifyed for Database description -- PH 2004-11-29
$databasedescription = validate($_POST['description'], 'description');
$result = $db->query('INSERT INTO `' . TABLE_PANEL_DATABASES . '` (`customerid`, `databasename`, `description`, `dbserver`) VALUES ("' . (int)$userinfo['customerid'] . '", "' . $db->escape($username) . '", "' . $db->escape($databasedescription) . '", "' . $db->escape($dbserver) . '")');
$result = $db->query('UPDATE `' . TABLE_PANEL_CUSTOMERS . '` SET `mysqls_used`=`mysqls_used`+1, `mysql_lastaccountnumber`=`mysql_lastaccountnumber`+1 WHERE `customerid`="' . (int)$userinfo['customerid'] . '"');
redirectTo($filename, Array('page' => $page, 's' => $s));
}
}
else
{
$mysql_servers = '';
foreach($sql_root as $mysql_server => $mysql_server_details)
{
$mysql_servers .= makeoption($mysql_server_details['caption'], $mysql_server);
} }
$mysql_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/mysql/formfield.mysql_add.php'; eval("echo \"" . getTemplate("mysql/mysqls_add") . "\";");
UI::view('user/form.html.twig', [
'formaction' => $linker->getLink(['section' => 'mysql']),
'formdata' => $mysql_add_data['mysql_add']
]);
} }
} }
} elseif ($action == 'edit' && $id != 0) { }
try { elseif($action == 'edit'
$json_result = Mysqls::getLocal($userinfo, [ && $id != 0)
'id' => $id {
])->get(); $result = $db->query_first('SELECT `id`, `databasename`, `description`, `dbserver` FROM `' . TABLE_PANEL_DATABASES . '` WHERE `customerid`="' . $userinfo['customerid'] . '" AND `id`="' . $id . '"');
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
if (isset($result['databasename']) && $result['databasename'] != '') { if(isset($result['databasename'])
if (isset($_POST['send']) && $_POST['send'] == 'send') { && $result['databasename'] != '')
try { {
$json_result = Mysqls::getLocal($userinfo, $_POST)->update(); if(!isset($sql_root[$result['dbserver']]) || !is_array($sql_root[$result['dbserver']]))
} catch (Exception $e) { {
Response::dynamicError($e->getMessage()); $result['dbserver'] = 0;
} }
Response::redirectTo($filename, [
'page' => $page if(isset($_POST['send'])
]); && $_POST['send'] == 'send')
} else { {
$mysql_servers = []; // Only change Password if it is set, do nothing if it is empty! -- PH 2004-11-29
try {
$result_json = MysqlServer::getLocal($userinfo)->listing(); $password = validate($_POST['mysql_password'], 'password');
$result_decoded = json_decode($result_json, true)['data']['list'];
foreach ($result_decoded as $dbserver => $dbdata) { if($password != '')
$mysql_servers[$dbserver] = $dbdata['caption'] . ' (' . $dbdata['host'] . (isset($dbdata['port']) && !empty($dbdata['port']) ? ':' . $dbdata['port'] : '').')'; {
// Begin root-session
$db_root = new db($sql_root[$result['dbserver']]['host'], $sql_root[$result['dbserver']]['user'], $sql_root[$result['dbserver']]['password'], '');
unset($db_root->password);
foreach(array_map('trim', explode(',', $settings['system']['mysql_access_host'])) as $mysql_access_host)
{
$db_root->query('SET PASSWORD FOR `' . $db_root->escape($result['databasename']) . '`@`' . $db_root->escape($mysql_access_host) . '` = PASSWORD(\'' . $db_root->escape($password) . '\')');
} }
} catch (Exception $e) {
/* just none */ $db_root->query('FLUSH PRIVILEGES');
$db_root->close();
// End root-session
} }
$mysql_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/mysql/formfield.mysql_edit.php'; // Update the Database description -- PH 2004-11-29
UI::view('user/form.html.twig', [ $log->logAction(USR_ACTION, LOG_INFO, "edited database '" . $result['databasename'] . "'");
'formaction' => $linker->getLink(['section' => 'mysql', 'id' => $id]), $databasedescription = validate($_POST['description'], 'description');
'formdata' => $mysql_edit_data['mysql_edit'], $result = $db->query('UPDATE `' . TABLE_PANEL_DATABASES . '` SET `description`="' . $db->escape($databasedescription) . '" WHERE `customerid`="' . (int)$userinfo['customerid'] . '" AND `id`="' . (int)$id . '"');
'editid' => $id redirectTo($filename, Array('page' => $page, 's' => $s));
]); }
else
{
eval("echo \"" . getTemplate("mysql/mysqls_edit") . "\";");
} }
} }
} }
} }
?>

414
customer_tickets.php Normal file
View File

@@ -0,0 +1,414 @@
<?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 Panel
* @version $Id$
*/
define('AREA', 'customer');
/**
* Include our init.php, which manages Sessions, Language etc.
*/
require ("./lib/init.php");
if(isset($_POST['id']))
{
$id = intval($_POST['id']);
}
elseif(isset($_GET['id']))
{
$id = intval($_GET['id']);
}
if($page == 'overview')
{
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_tickets");
eval("echo \"" . getTemplate("ticket/ticket") . "\";");
}
elseif($page == 'tickets')
{
if($action == '')
{
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_tickets::tickets");
$fields = array(
'status' => $lng['ticket']['status'],
'priority' => $lng['ticket']['priority'],
'lastchange' => $lng['ticket']['lastchange'],
'ticket_answers' => $lng['ticket']['ticket_answers'],
'subject' => $lng['ticket']['subject'],
'lastreplier' => $lng['ticket']['lastreplier']
);
$paging = new paging($userinfo, $db, TABLE_PANEL_TICKETS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']);
$paging->sortfield = 'lastchange';
$paging->sortorder = 'desc';
$result = $db->query('SELECT `main`.`id`, (SELECT COUNT(`sub`.`id`) FROM `' . TABLE_PANEL_TICKETS . '` `sub` WHERE `sub`.`answerto` = `main`.`id`) as `ticket_answers`, `main`.`lastchange`, `main`.`subject`, `main`.`status`, `main`.`lastreplier`, `main`.`priority` FROM `' . TABLE_PANEL_TICKETS . '` as `main` WHERE `main`.`answerto` = "0" AND `archived` = "0" AND `customerid`="' . (int)$userinfo['customerid'] . '" AND `adminid`="' . (int)$userinfo['adminid'] . '" ' . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
$paging->setEntries($db->num_rows($result));
$sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$i = 0;
$count = 0;
$tickets = '';
$tickets_count = 0;
while($row = $db->fetch_array($result))
{
if($paging->checkDisplay($i))
{
$tickets_count++;
$row = htmlentities_array($row);
$row['lastchange'] = date("d.m.y H:i", $row['lastchange']);
if($row['status'] >= 0
&& $row['status'] <= 2)
{
$reopen = 0;
}
else
{
$reopen = 1;
}
$row['status'] = ticket::getStatusText($lng, $row['status']);
$row['priority'] = ticket::getPriorityText($lng, $row['priority']);
if($row['lastreplier'] == '1')
{
$row['lastreplier'] = $lng['ticket']['staff'];
$cananswer = 1;
}
else
{
$row['lastreplier'] = $lng['ticket']['customer'];
$cananswer = 0;
}
if(strlen($row['subject']) > 20)
{
$row['subject'] = substr($row['subject'], 0, 17) . '...';
}
eval("\$tickets.=\"" . getTemplate("ticket/tickets_tickets") . "\";");
$count++;
}
$i++;
}
$supportavailable = 0;
$time = date("Hi", time());
$day = date("w", time());
$start = substr($settings['ticket']['worktime_begin'], 0, 2) . substr($settings['ticket']['worktime_begin'], 3, 2);
$end = substr($settings['ticket']['worktime_end'], 0, 2) . substr($settings['ticket']['worktime_end'], 3, 2);
if($time >= $start
&& $time <= $end)
{
$supportavailable = 1;
}
if($settings['ticket']['worktime_sat'] == "0"
&& $day == "6")
{
$supportavailable = 0;
}
if($settings['ticket']['worktime_sun'] == "0"
&& $day == "0")
{
$supportavailable = 0;
}
if($settings['ticket']['worktime_all'] == "1")
{
$supportavailable = 1;
}
$ticketsopen = 0;
$opentickets = $db->query_first('SELECT COUNT(`id`) as `count` FROM `' . TABLE_PANEL_TICKETS . '`
WHERE `customerid` = "' . $userinfo['customerid'] . '"
AND `answerto` = "0"
AND (`status` = "0" OR `status` = "1" OR `status` = "2")');
if($settings['ticket']['concurrently_open'] != - 1
&& $settings['ticket']['concurrently_open'] != '')
{
$notmorethanxopentickets = strtr($lng['ticket']['notmorethanxopentickets'], array('%s' => $settings['ticket']['concurrently_open']));
}
else
{
$notmorethanxopentickets = '';
}
$ticketsopen = (int)$opentickets['count'];
eval("echo \"" . getTemplate("ticket/tickets") . "\";");
}
elseif($action == 'new')
{
if($userinfo['tickets_used'] < $userinfo['tickets']
|| $userinfo['tickets'] == '-1')
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$newticket = ticket::getInstanceOf($userinfo, $db, $settings, -1);
$newticket->Set('subject', validate($_POST['subject'], 'subject'), true, false);
$newticket->Set('priority', validate($_POST['priority'], 'priority'), true, false);
$newticket->Set('category', validate($_POST['category'], 'category'), true, false);
$newticket->Set('customer', (int)$userinfo['customerid'], true, false);
$newticket->Set('admin', (int)$userinfo['adminid'], true, false);
$newticket->Set('message', validate(str_replace("\r\n", "\n", $_POST['message']), 'message', '/^[^\0]*$/'), true, false);
if($newticket->Get('subject') == null)
{
standard_error(array('stringisempty', 'mysubject'));
}
elseif($newticket->Get('message') == null)
{
standard_error(array('stringisempty', 'mymessage'));
}
else
{
$now = time();
$newticket->Set('dt', $now, true, true);
$newticket->Set('lastchange', $now, true, true);
$newticket->Set('ip', $_SERVER['REMOTE_ADDR'], true, true);
$newticket->Set('status', '0', true, true);
$newticket->Set('lastreplier', '0', true, true);
$newticket->Set('by', '0', true, true);
$newticket->Insert();
$log->logAction(USR_ACTION, LOG_NOTICE, "opened support-ticket '" . $newticket->Get('subject') . "'");
$db->query('UPDATE `' . TABLE_PANEL_CUSTOMERS . '`
SET `tickets_used`=`tickets_used`+1 WHERE `customerid`="' . (int)$userinfo['customerid'] . '"');
// Customer mail
$newticket->sendMail((int)$userinfo['customerid'], 'new_ticket_for_customer_subject', $lng['mails']['new_ticket_for_customer']['subject'], 'new_ticket_for_customer_mailbody', $lng['mails']['new_ticket_for_customer']['mailbody']);
// Admin mail
$newticket->sendMail(-1, 'new_ticket_by_customer_subject', $lng['mails']['new_ticket_by_customer']['subject'], 'new_ticket_by_customer_mailbody', $lng['mails']['new_ticket_by_customer']['mailbody']);
redirectTo($filename, Array('page' => $page, 's' => $s));
}
}
else
{
$categories = '';
$result = $db->query_first('SELECT `id`, `name` FROM `' . TABLE_PANEL_TICKET_CATS . '` ORDER BY `name` ASC');
if(isset($result['name'])
&& $result['name'] != '')
{
$result2 = $db->query('SELECT `id`, `name` FROM `' . TABLE_PANEL_TICKET_CATS . '` ORDER BY `name` ASC');
while($row = $db->fetch_array($result2))
{
$categories.= makeoption($row['name'], $row['id']);
}
}
else
{
$categories = makeoption($lng['ticket']['no_cat'], '0');
}
$priorities = makeoption($lng['ticket']['unf_high'], '1');
$priorities.= makeoption($lng['ticket']['unf_normal'], '2');
$priorities.= makeoption($lng['ticket']['unf_low'], '3');
$ticketsopen = 0;
$opentickets = $db->query_first('SELECT COUNT(`id`) as `count` FROM `' . TABLE_PANEL_TICKETS . '`
WHERE `customerid` = "' . $userinfo['customerid'] . '"
AND `answerto` = "0"
AND (`status` = "0" OR `status` = "1" OR `status` = "2")');
if($settings['ticket']['concurrently_open'] != - 1
&& $settings['ticket']['concurrently_open'] != '')
{
$notmorethanxopentickets = strtr($lng['ticket']['notmorethanxopentickets'], array('%s' => $settings['ticket']['concurrently_open']));
}
else
{
$notmorethanxopentickets = '';
}
$ticketsopen = (int)$opentickets['count'];
eval("echo \"" . getTemplate("ticket/tickets_new") . "\";");
}
}
else
{
standard_error('nomoreticketsavailable');
}
}
elseif($action == 'answer'
&& $id != 0)
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$replyticket = ticket::getInstanceOf($userinfo, $db, $settings, -1);
$replyticket->Set('subject', validate($_POST['subject'], 'subject'), true, false);
$replyticket->Set('priority', validate($_POST['priority'], 'priority'), true, false);
$replyticket->Set('message', validate(str_replace("\r\n", "\n", $_POST['message']), 'message', '/^[^\0]*$/'), true, false);
if($replyticket->Get('message') == null)
{
standard_error(array('stringisempty', 'mymessage'));
}
else
{
$now = time();
$replyticket->Set('customerid', (int)$userinfo['customerid'], true, true);
$replyticket->Set('lastchange', $now, true, true);
$replyticket->Set('ip', $_SERVER['REMOTE_ADDR'], true, true);
$replyticket->Set('status', '1', true, true);
$replyticket->Set('answerto', (int)$id, true, false);
$replyticket->Set('by', '0', true, true);
$replyticket->Insert();
// Update priority if changed
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
if($replyticket->Get('priority') != $mainticket->Get('priority'))
{
$mainticket->Set('priority', $replyticket->Get('priority'), true);
}
$mainticket->Set('lastchange', $now);
$mainticket->Set('lastreplier', '0');
$mainticket->Set('status', '1');
$mainticket->Update();
$log->logAction(USR_ACTION, LOG_NOTICE, "answered support-ticket '" . $mainticket->Get('subject') . "'");
$mainticket->sendMail(-1, 'new_reply_ticket_by_customer_subject', $lng['mails']['new_reply_ticket_by_customer']['subject'], 'new_reply_ticket_by_customer_mailbody', $lng['mails']['new_reply_ticket_by_customer']['mailbody']);
redirectTo($filename, Array('page' => $page, 's' => $s));
}
}
else
{
$ticket_replies = '';
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
$dt = date("d.m.Y H:i\h", $mainticket->Get('dt'));
$status = ticket::getStatusText($lng, $mainticket->Get('status'));
if($mainticket->Get('status') >= 0
&& $mainticket->Get('status') <= 2)
{
$isclosed = 0;
}
else
{
$isclosed = 1;
}
if($mainticket->Get('by') == '1')
{
$by = $lng['ticket']['staff'];
}
else
{
$by = $lng['ticket']['customer'];
}
$subject = $mainticket->Get('subject');
$message = $mainticket->Get('message');
eval("\$ticket_replies.=\"" . getTemplate("ticket/tickets_tickets_main") . "\";");
$result = $db->query('SELECT `name` FROM `' . TABLE_PANEL_TICKET_CATS . '`
WHERE `id`="' . (int)$mainticket->Get('category') . '"');
$row = $db->fetch_array($result);
$andere = $db->query('SELECT * FROM `' . TABLE_PANEL_TICKETS . '` WHERE `answerto`="' . (int)$id . '" ORDER BY `lastchange` ASC');
while($row2 = $db->fetch_array($andere))
{
$subticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$row2['id']);
$lastchange = date("d.m.Y H:i\h", $subticket->Get('lastchange'));
if($subticket->Get('by') == '1')
{
$by = $lng['ticket']['staff'];
}
else
{
$by = $lng['ticket']['customer'];
}
$subject = $subticket->Get('subject');
$message = $subticket->Get('message');
eval("\$ticket_replies.=\"" . getTemplate("ticket/tickets_tickets_list") . "\";");
}
$priorities = makeoption($lng['ticket']['high'], '1', $mainticket->Get('priority'), true, true);
$priorities.= makeoption($lng['ticket']['normal'], '2', $mainticket->Get('priority'), true, true);
$priorities.= makeoption($lng['ticket']['low'], '3', $mainticket->Get('priority'), true, true);
$subject = $mainticket->Get('subject');
$ticket_replies_count = $db->num_rows($andere) + 1;
// don't forget the main-ticket!
eval("echo \"" . getTemplate("ticket/tickets_reply") . "\";");
}
}
elseif($action == 'close'
&& $id != 0)
{
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$now = time();
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
$mainticket->Set('lastchange', $now, true, true);
$mainticket->Set('lastreplier', '0', true, true);
$mainticket->Set('status', '3', true, true);
$mainticket->Update();
$log->logAction(USR_ACTION, LOG_NOTICE, "closed support-ticket '" . $mainticket->Get('subject') . "'");
redirectTo($filename, Array('page' => $page, 's' => $s));
}
else
{
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
ask_yesno('ticket_reallyclose', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $mainticket->Get('subject'));
}
}
elseif($action == 'reopen'
&& $id != 0)
{
$ticketsopen = 0;
$opentickets = $db->query_first('SELECT COUNT(`id`) as `count` FROM `' . TABLE_PANEL_TICKETS . '`
WHERE `customerid` = "' . $userinfo['customerid'] . '"
AND `answerto` = "0"
AND (`status` = "0" OR `status` = "1" OR `status` = "2")');
$ticketsopen = (int)$opentickets['count'];
if($ticketsopen > $settings['ticket']['concurrently_open']
&& $settings['ticket']['concurrently_open'] != - 1
&& $settings['ticket']['concurrently_open'] != '')
{
standard_error('notmorethanxopentickets', $settings['ticket']['concurrently_open']);
}
$now = time();
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$id);
$mainticket->Set('lastchange', $now, true, true);
$mainticket->Set('lastreplier', '0', true, true);
$mainticket->Set('status', '0', true, true);
$mainticket->Update();
$log->logAction(USR_ACTION, LOG_NOTICE, "reopened support-ticket '" . $mainticket->Get('subject') . "'");
redirectTo($filename, Array('page' => $page, 's' => $s));
}
}
?>

View File

@@ -2,52 +2,277 @@
/** /**
* 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 * @version $Id$
* 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 = 'customer'; define('AREA', 'customer');
require __DIR__ . '/lib/init.php';
use Froxlor\Traffic\Traffic; /**
use Froxlor\Settings; * Include our init.php, which manages Sessions, Language etc.
use Froxlor\UI\Panel\UI; */
use Froxlor\UI\Request;
use Froxlor\UI\Response;
// redirect if this customer page is hidden via settings require ("./lib/init.php");
if (Settings::IsInList('panel.customer_hide_options', 'traffic')) { $traffic = '';
Response::redirectTo('customer_index.php'); $month = null;
$year = null;
if(isset($_POST['month'])
&& isset($_POST['year']))
{
$month = intval($_POST['month']);
$year = intval($_POST['year']);
}
elseif(isset($_GET['month'])
&& isset($_GET['year']))
{
$month = intval($_GET['month']);
$year = intval($_GET['year']);
} }
$range = Request::any('range', 'currentyear'); //BAM! $_GET???
if ($page == 'current') { elseif (isset($_GET['page'])
$range = 'currentmonth'; && $_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)
$context = Traffic::getCustomerStats($userinfo, $range); && !is_null($year))
} catch (Exception $e) { {
Response::dynamicError($e->getMessage()); $traf['byte'] = 0;
$result = $db->query("SELECT MAX(`http`), MAX(`ftp_up`+`ftp_down`), MAX(`mail`)
FROM `" . TABLE_PANEL_TRAFFIC . "`
WHERE `customerid`='" . $userinfo['customerid'] . "'
AND `month` = '" . $month . "'
AND `year` = '" . $year . "'");
rsort($row = mysql_fetch_row($result));
$traf['max'] = ($row[0] > $row[1] ? ($row[0] > $row[2] ? $row[0] : $row[2]) : ($row[1] > $row[2] ? $row[1] : $row[2]));;
$result = $db->query("SELECT
SUM(`http`) as 'http', SUM(`ftp_up`) AS 'ftp_up', SUM(`ftp_down`) as 'ftp_down', SUM(`mail`) as 'mail',
`day`, `month`, `year`
FROM `" . TABLE_PANEL_TRAFFIC . "`
WHERE `customerid`='" . $userinfo['customerid'] . "'
AND `month` = '" . $month . "' AND `year` = '" . $year . "'
GROUP BY `day` ORDER BY `day` ASC");
$traffic_complete['http'] = 0;
$traffic_complete['ftp'] = 0;
$traffic_complete['mail'] = 0;
$show = '';
while($row = $db->fetch_array($result))
{
$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['panel']['decimal_places']) . " MB up/ " . bcdiv($row['ftp_down'], 1024, $settings['panel']['decimal_places']) . " MB down (FTP)";
$traf['httptext'] = bcdiv($http, 1024, $settings['panel']['decimal_places']) . " MB (HTTP)";
$traf['mailtext'] = bcdiv($mail, 1024, $settings['panel']['decimal_places']) . " MB (Mail)";
}
else
{
$traf['ftptext'] = round($row['ftp_up'] / 1024, $settings['panel']['decimal_places']) . " MB up/ " . round($row['ftp_down'] / 1024, $settings['panel']['decimal_places']) . " MB down (FTP)";
$traf['httptext'] = round($http / 1024, $settings['panel']['decimal_places']) . " MB (HTTP)";
$traf['mailtext'] = round($mail / 1024, $settings['panel']['decimal_places']) . " MB (Mail)";
}
if($traf['byte'] != 0
&& $traf['max'] != 0)
{
$proz = $traf['max'] / 100;
$traf['http'] = round($http / $proz, 0);
$traf['ftp'] = round($ftp / $proz, 0);
$traf['mail'] = round($mail / $proz, 0);
if($traf['http'] == 0)
{
$traf['http'] = 1;
}
if($traf['ftp'] == 0)
{
$traf['ftp'] = 1;
}
if($traf['mail'] == 0)
{
$traf['mail'] = 1;
}
}
else
{
$traf['http'] = 0;
$traf['ftp'] = 0;
$traf['mail'] = 0;
}
if(extension_loaded('bcmath'))
{
$traf['byte'] = bcdiv($traf['byte'], 1024, $settings['panel']['decimal_places']);
}
else
{
$traf['byte'] = round($traf['byte'] / 1024, $settings['panel']['decimal_places']);
}
eval("\$traffic.=\"" . getTemplate("traffic/traffic_month") . "\";");
$show = $lng['traffic']['months'][intval($row['month'])] . " " . $row['year'];
}
if(extension_loaded('bcmath'))
{
$traffic_complete['http'] = bcdiv($traffic_complete['http'], 1024, $settings['panel']['decimal_places']);
$traffic_complete['ftp'] = bcdiv($traffic_complete['ftp'], 1024, $settings['panel']['decimal_places']);
$traffic_complete['mail'] = bcdiv($traffic_complete['mail'], 1024, $settings['panel']['decimal_places']);
}
else
{
$traffic_complete['http'] = round($traffic_complete['http'] / 1024, $settings['panel']['decimal_places']);
$traffic_complete['ftp'] = round($traffic_complete['ftp'] / 1024, $settings['panel']['decimal_places']);
$traffic_complete['mail'] = round($traffic_complete['mail'] / 1024, $settings['panel']['decimal_places']);
}
eval("echo \"" . getTemplate("traffic/traffic_details") . "\";");
}
else
{
$result = $db->query("(SELECT SUM(`http`) as sum FROM `" . TABLE_PANEL_TRAFFIC . "`
WHERE `customerid` = '" . $userinfo['customerid'] . "'
GROUP BY CONCAT(`year`,`month`) ORDER BY CONCAT(`year`,`month`) DESC LIMIT 12) UNION
(SELECT SUM(`ftp_up`+`ftp_down`) FROM `" . TABLE_PANEL_TRAFFIC . "`
WHERE `customerid` = '" . $userinfo['customerid'] . "'
GROUP BY CONCAT(`year`,`month`) ORDER BY CONCAT(`year`,`month`) DESC LIMIT 12) UNION
(SELECT SUM(`mail`) FROM `" . TABLE_PANEL_TRAFFIC . "`
WHERE `customerid` = '" . $userinfo['customerid'] . "'
GROUP BY CONCAT(`year`,`month`) ORDER BY CONCAT(`year`,`month`) DESC LIMIT 12) ORDER BY sum DESC LIMIT 1");
$row = $db->fetch_array($result);
$traf['max'] = ($row[0] > $row[1] ? ($row[0] > $row[2] ? $row[0] : $row[2]) : ($row[1] > $row[2] ? $row[1] : $row[2]));;
$result = $db->query("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` = '" . $userinfo['customerid'] . "'
GROUP BY CONCAT(`year`,`month`) ORDER BY CONCAT(`year`,`month`) DESC LIMIT 12");
$traffic_complete['http'] = 0;
$traffic_complete['ftp'] = 0;
$traffic_complete['mail'] = 0;
while($row = $db->fetch_array($result))
{
$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 * 1024, $settings['panel']['decimal_places']) . " GB up/ " . bcdiv($ftp_down, 1024 * 1024, $settings['panel']['decimal_places']) . " GB down (FTP)";
$traf['httptext'] = bcdiv($http, 1024 * 1024, $settings['panel']['decimal_places']) . " GB (HTTP)";
$traf['mailtext'] = bcdiv($mail, 1024 * 1024, $settings['panel']['decimal_places']) . " GB (Mail)";
}
else
{
$traf['ftptext'] = round($ftp_up / 1024 * 1024, $settings['panel']['decimal_places']) . " GB up/ " . round($ftp_down / 1024 * 1024, $settings['panel']['decimal_places']) . " GB down (FTP)";
$traf['httptext'] = round($http / 1024 * 1024, $settings['panel']['decimal_places']) . " GB (HTTP)";
$traf['mailtext'] = round($mail / 1024 * 1024, $settings['panel']['decimal_places']) . " GB (Mail)";
}
if($traf['max'] != 0)
{
$proz = $traf['max'] / 100;
$traf['ftp'] = round(($ftp_up + $ftp_down) / $proz, 0);
$traf['http'] = round($http / $proz, 0);
$traf['mail'] = round($mail / $proz, 0);
if($traf['http'] == 0)
{
$traf['http'] = 1;
}
if($traf['ftp'] == 0)
{
$traf['ftp'] = 1;
}
if($traf['mail'] == 0)
{
$traf['mail'] = 1;
}
}
else
{
$traf['ftp'] = 0;
$traf['http'] = 0;
$traf['mail'] = 0;
}
if(extension_loaded('bcmath'))
{
$traf['byte'] = bcadd($traf['byte'] / (1024 * 1024), 0.0000, 4);
}
else
{
$traf['byte'] = round($traf['byte'] + (1024 * 1024), 4);
}
eval("\$traffic.=\"" . getTemplate("traffic/traffic_traffic") . "\";");
}
if(extension_loaded('bcmath'))
{
$traffic_complete['http'] = bcdiv($traffic_complete['http'], 1024 * 1024, $settings['panel']['decimal_places']);
$traffic_complete['ftp'] = bcdiv($traffic_complete['ftp'], 1024 * 1024, $settings['panel']['decimal_places']);
$traffic_complete['mail'] = bcdiv($traffic_complete['mail'], 1024 * 1024, $settings['panel']['decimal_places']);
}
else
{
$traffic_complete['http'] = round($traffic_complete['http'] / 1024 * 1024, $settings['panel']['decimal_places']);
$traffic_complete['ftp'] = round($traffic_complete['ftp'] / 1024 * 1024, $settings['panel']['decimal_places']);
$traffic_complete['mail'] = round($traffic_complete['mail'] / 1024 * 1024, $settings['panel']['decimal_places']);
}
eval("echo \"" . getTemplate("traffic/traffic") . "\";");
} }
// pass metrics to the view ?>
UI::view('user/traffic.html.twig', $context);

View File

@@ -1,149 +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\Api\Commands\DomainZones;
use Froxlor\Dns\Dns;
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;
// This file is being included in admin_domains and customer_domains
// and therefore does not need to require lib/init.php
$domain_id = (int)Request::any('domain_id');
$record = isset($_POST['dns_record']) ? trim($_POST['dns_record']) : null;
$type = isset($_POST['dns_type']) ? $_POST['dns_type'] : 'A';
$prio = isset($_POST['dns_mxp']) ? (int)$_POST['dns_mxp'] : null;
$content = isset($_POST['dns_content']) ? trim($_POST['dns_content']) : null;
$ttl = isset($_POST['dns_ttl']) ? (int)$_POST['dns_ttl'] : 18000;
// get domain-name
$domain = Dns::getAllowedDomainEntry($domain_id, AREA, $userinfo);
$errors = "";
$success_message = "";
// action for adding a new entry
if ($action == 'add_record' && !empty($_POST)) {
try {
DomainZones::getLocal($userinfo, [
'id' => $domain_id,
'record' => $record,
'type' => $type,
'prio' => $prio,
'content' => $content,
'ttl' => $ttl
])->add();
$success_message = lng('success.dns_record_added');
$record = $prio = $content = "";
} catch (Exception $e) {
$errors = str_replace("\n", "<br>", $e->getMessage());
}
} 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
if ($entry_id > 0 && $domain_id > 0) {
try {
DomainZones::getLocal($userinfo, [
'entry_id' => $entry_id,
'id' => $domain_id
])->delete();
// success message (inline)
$success_message = lng('success.dns_record_deleted');
} catch (Exception $e) {
$errors = str_replace("\n", "<br>", $e->getMessage());
}
}
}
// select all entries
try {
$dns_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/tablelisting.dns.php';
$collection = (new Collection(DomainZones::class, $userinfo, ['id' => $domain_id]))
->withPagination($dns_list_data['dns_list']['columns'], $dns_list_data['dns_list']['default_sorting']);
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
try {
$json_result = DomainZones::getLocal($userinfo, [
'id' => $domain_id
])->get();
} catch (Exception $e) {
Response::dynamicError($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$zonefile = implode("\n", $result);
$dns_add_data = include_once dirname(__FILE__) . '/lib/formfields/formfield.dns_add.php';
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

@@ -1,67 +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
*/
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)
{
$this->url = $url;
$this->key = $key;
$this->secret = $secret;
}
public function request($command, array $data = [])
{
$payload = [
'command' => $command,
'params' => $data
];
$ch = curl_init($this->url);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERPWD, $this->key . ":" . $this->secret);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, 1);
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);
return json_decode($result ?? curl_error($ch), true);
}
public function getLastStatusCode(): ?string
{
return $this->lastStatusCode;
}
}

View File

@@ -1,46 +0,0 @@
<?php
// include FroxlorAPI helper class
require __DIR__ . '/FroxlorAPI.php';
// 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');
// customer data
$data = [
'new_loginname' => 'test',
'email' => 'test@froxlor.org',
'firstname' => 'Test',
'name' => 'Testman',
'customernumber' => 1337,
'new_customer_password' => 's0mEcRypt1cpassword' . uniqid()
];
// send request
$response = $fapi->request('Customers.add', $data);
// check for error
if ($fapi->getLastStatusCode() != 200) {
echo "HTTP-STATUS: " . $fapi->getLastStatusCode() . PHP_EOL;
echo "Description: " . $response['message'] . PHP_EOL;
exit();
}
// view response data
var_dump($response);
/*
array(60) {
["customerid"]=>
string(1) "1"
["loginname"]=>
string(4) "test"
["password"]=>
string(63) "$5$asdasdasd.asdasd"
["adminid"]=>
string(1) "1"
["name"]=>
string(7) "Testman"
["firstname"]=>
string(4) "Test"
[...]
*/

View File

View File

@@ -1,20 +0,0 @@
<?php
// include FroxlorAPI helper class
require __DIR__ . '/FroxlorAPI.php';
// create object of FroxlorAPI with URL, apikey and apisecret
$fapi = new FroxlorAPI('http://localhost/api.php', 'your-api-key', 'your-api-secret');
// send request
$response = $fapi->request('Froxlor.listFunctions');
// check for error
if ($fapi->getLastStatusCode() != 200) {
echo "HTTP-STATUS: " . $fapi->getLastStatusCode() . PHP_EOL;
echo "Description: " . $response['message'] . PHP_EOL;
exit();
}
// view response data
var_dump($response);

View File

View File

@@ -1,111 +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;
// 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";
$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);
}

BIN
images/ball.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 B

BIN
images/changelanguage.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

BIN
images/default.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
images/endsection.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

BIN
images/error.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
images/error.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
images/footer.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
images/header.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
images/header_r.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
images/info.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
images/login.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
images/logininternal.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

BIN
images/order_asc.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 B

BIN
images/order_desc.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 B

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