Compare commits

..

6 Commits

Author SHA1 Message Date
Michael Kaufmann
00eb5ed87b set version to 0.9.40.1 for bugfix release
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2018-11-27 18:41:05 +01:00
Michael Kaufmann
1dc9ea6fb1 Merge branch '0.9.x' of github.com:Froxlor/Froxlor into 0.9.x 2018-11-27 11:50:25 +01:00
Michael Kaufmann
1b63936a26 fix typo in function name, fixes #601
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2018-11-27 11:50:05 +01:00
Michael Kaufmann
4760bddfe0 Merge pull request #585 from Xavjer/0.9.x
#584 - PHP deprecated warning
2018-11-13 17:38:54 +01:00
Cédric Wyss
03f62365b1 #584 - Revert change for PHP <=5.4.6 2018-11-13 17:29:39 +01:00
Cédric Wyss
3c0416ac44 #584 - PHP deprecated warning 2018-11-13 16:02:37 +01:00
1034 changed files with 56815 additions and 88240 deletions

View File

@@ -1,40 +0,0 @@
kind: pipeline
name: deploy-froxlor
type: docker
platform:
os: linux
arch: arm64
trigger:
branch:
- live
event:
include:
- push
steps:
- name: deploy
image: cr.wks/drone/drone-rsync:latest
settings:
hosts: ["rechner02.maketank.net"]
source: ./
target: ~/froxlor-test
user: www-data
exclude: ['vendor', '.git*', '*drone.yml', '.settings', '.buildpath', '.editorconfig', '.project', '.travis.yml']
args: '-v --delete'
log_level: quiet
key:
from_secret: ssh-www-data-maketank-rsa
command_timeout: 10m
- name: compose-install
image: appleboy/drone-ssh
settings:
host:
- rechner02.maketank.net
username: www-data
key:
from_secret: ssh-www-data-maketank-rsa
script:
- cd ~/froxlor-test && composer install --no-dev

View File

@@ -2,12 +2,15 @@
Before you start working on a PR, contact us via IRC in #froxlor on Freenode or Before you start working on a PR, contact us via IRC in #froxlor on Freenode or
the forum at https://forum.froxlor.org to get a clue whether someone else isn't the forum at https://forum.froxlor.org to get a clue whether someone else isn't
already working on it or if we don not want/need this certain change. already working on it or if we don't want to invest the effort in favour of
working on Froxlor 2.0.
Of course, bug fixes are always welcome. Of course, bug fixes are always welcome.
However, at this stage of the 0.9.x branch, we are not looking for new However, at this stage of the 0.9.x branch, we are not looking for new
features or refactoring, especially not the kind which requires changes to a features or refactoring, especially not the kind which requires changes to a
lot of files. lot of files.
Please focus on our API based version 0.10.x (current master). Currently, we are working on a complete re-write, which, at this point in
time, is not yet public to keep delays due to discussions about internal
details to a minimum.
@@ -32,7 +35,7 @@ Thanks!
### Webserver changes ### Webserver changes
If you make changes to the functionality of webserver configuration, please If you make changes to the functionality of webserver configuration, please
make sure your implementation covers all supported webservers. make sure your implementation covers both apache **and** nginx.
@@ -48,10 +51,8 @@ strings in
### New settings and database-layout changes ### New settings
If you add new settings or layout changes, please make sure you add these to If you add new settings, please make sure you add the default values to
* `install/froxlor.sql` * `install/froxlor.sql`
* and handle the update (see `install/updates/froxlor/0.10/update_0.10.inc.php`) * handle the update (see `install/updates/froxlor/0.9/update_0.9.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,6 +1,6 @@
# Bug report vs. support request # Bug report vs. support request
If you're unsure of whether your problem is a bug or a configuration error If you're unsure of whether your problem is a bug or a configuration error
* contact us via IRC in #froxlor on irc.libera.chat * contact us via IRC in #froxlor on freenode
* or post a thread in our forum at https://forum.froxlor.org * or post a thread in our forum at https://forum.froxlor.org
As a rule of thumb: before reporting an issue As a rule of thumb: before reporting an issue

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,38 +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,80 +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.0']
mariadb-version: [10.5, 10.4]
steps:
- name: Checkout
uses: actions/checkout@v2
- 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
- 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'@'%';"
mysql -h 127.0.0.1 --protocol=TCP -u root -pfr0xl0r.TravisCI froxlor010 < install/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,57 +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.0']
mysql-version: [8.0, 5.7]
steps:
- name: Checkout
uses: actions/checkout@v2
- 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
- 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'@'%';"
mysql -h 127.0.0.1 --protocol=TCP -u root -pfr0xl0r.TravisCI froxlor010 < install/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'@'%';"
mysql -h 127.0.0.1 --protocol=TCP -u root -pfr0xl0r.TravisCI froxlor010 < install/froxlor.sql
- name: Run testing
run: ant quick-build

7
.gitignore vendored
View File

@@ -1,9 +1,7 @@
install/update.log install/update.log
templates/* templates/*
lib/userdata.inc.php lib/userdata.inc.php
lib/userdata.inc.php.bak
logs/* logs/*
!logs/index.html
.buildpath .buildpath
.project .project
.settings/ .settings/
@@ -12,11 +10,8 @@ logs/*
.well-known .well-known
.idea .idea
*.iml *.iml
img/
!templates/Maketank/
!templates/Froxlor/ !templates/Froxlor/
!templates/Sparkle/ !templates/Sparkle/
!templates/misc/ !templates/misc/
templates/Sparkle/assets/css/custom.css templates/Froxlor/assets/img/logo_custom.png
vendor/

View File

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

90
2fa.php
View File

@@ -1,90 +0,0 @@
<?php
if (! defined('AREA')) {
header("Location: index.php");
exit();
}
use Froxlor\Database\Database;
use Froxlor\Settings;
if (Settings::Get('2fa.enabled') != '1') {
\Froxlor\UI\Response::dynamic_error("2FA not activated");
}
/**
* This file is part of the Froxlor project.
* Copyright (c) 2018 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2018-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Panel
* @since 0.10.0
*
*/
// This file is being included in admin_index and customer_index
// 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 \Froxlor\FroxlorTwoFactorAuth('Froxlor ' . Settings::Get('system.hostname'));
// do the delete and then just show a success-message
if ($action == 'delete') {
Database::pexecute($upd_stmt, array(
't2fa' => 0,
'd2fa' => "",
'id' => $uid
));
\Froxlor\UI\Response::standard_success($lng['2fa']['2fa_removed']);
} elseif ($action == 'add') {
$type = isset($_POST['type_2fa']) ? $_POST['type_2fa'] : '0';
if ($type == 0 || $type == 1) {
$data = "";
}
if ($type == 2) {
// generate secret for TOTP
$data = $tfa->createSecret();
}
Database::pexecute($upd_stmt, array(
't2fa' => $type,
'd2fa' => $data,
'id' => $uid
));
\Froxlor\UI\Response::standard_success(sprintf($lng['2fa']['2fa_added'], $filename, $s));
}
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed 2fa::overview");
if ($userinfo['type_2fa'] == '0') {
// available types
$type_select_values = array(
0 => '-',
1 => 'E-Mail',
2 => 'Authenticator'
);
asort($type_select_values);
$type_select = "";
foreach ($type_select_values as $_val => $_type) {
$type_select .= \Froxlor\UI\HTML::makeoption($_type, $_val);
}
} elseif ($userinfo['type_2fa'] == '1') {
// email 2fa enabled
} elseif ($userinfo['type_2fa'] == '2') {
// authenticator 2fa enabled
$ga_qrcode = $tfa->getQRCodeImageAsDataUri($userinfo['loginname'], $userinfo['data_2fa']);
}
eval("echo \"" . \Froxlor\UI\Template::getTemplate("2fa/overview", true) . "\";");

View File

@@ -1,7 +1,3 @@
[![Froxlor-CI](https://github.com/Froxlor/Froxlor/actions/workflows/build-mariadb.yml/badge.svg?branch=master)](https://github.com/Froxlor/Froxlor/actions/workflows/build-mariadb.yml)
[![Froxlor-CI](https://github.com/Froxlor/Froxlor/actions/workflows/build-mysql.yml/badge.svg?branch=master)](https://github.com/Froxlor/Froxlor/actions/workflows/build-mysql.yml)
[![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.froxlor.org)
# Froxlor # Froxlor
The server administration software for your needs. The server administration software for your needs.
@@ -21,20 +17,16 @@ Developed by experienced server administrators, this panel simplifies the effort
9. Have fun! 9. Have fun!
### Detailed installation ### Detailed installation
https://docs.froxlor.org/general/installation/index.html https://github.com/Froxlor/Froxlor/wiki/Install-froxlor-from-tarball
## Help ## Help
You may find help in the following places: You may find help in the following places:
### Discord
The froxlor community discord server can be found here: https://discord.froxlor.org
### IRC ### IRC
froxlor may be found on libera.chat, channel #froxlor: froxlor may be found on freenode.net, channel #froxlor:
irc://irc.libera.chat/froxlor irc://chat.freenode.net/froxlor
### Forum ### Forum
@@ -42,37 +34,30 @@ The community is located on https://forum.froxlor.org/
### Wiki ### Wiki
More documentation may be found in the froxlor - documentation: More documentation may be found in the froxlor - wiki:
https://docs.froxlor.org/ https://github.com/Froxlor/Froxlor/wiki
## License ## License
May be found in [COPYING](COPYING) May be found in COPYING
## Downloads ## Downloads
### Tarball ### Tarball
https://files.froxlor.org/releases/froxlor-latest.tar.gz [MD5](https://files.froxlor.org/releases/froxlor-latest.tar.gz.md5) [SHA1](https://files.froxlor.org/releases/froxlor-latest.tar.gz.sha1) https://files.froxlor.org/releases/froxlor-latest.tar.gz [MD5](https://files.froxlor.org/releases/froxlor-latest.tar.gz.md5) [SHA1](https://files.froxlor.org/releases/froxlor-latest.tar.gz.sha1)
### Debian / Ubutnu repository ### Debian repository
[HowTo](https://docs.froxlor.org/general/installation/aptpackage.html) [HowTo](https://github.com/Froxlor/Froxlor/wiki/Install-froxlor-on-debian)
#### Debian /etc/apt/sources.list.d/froxlor.list
> deb http://debian.froxlor.org {wheezy|jessie|stretch} main
``` ### Gentoo repository
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
sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.froxlor.org-froxlor.gpg] https://deb.froxlor.org/debian $(lsb_release -sc) main" > /etc/apt/sources.list.d/froxlor.list'
```
#### Ubuntu [HowTo](https://github.com/Froxlor/Froxlor/wiki/Install-froxlor-on-gentoo)
``` https://files.froxlor.org/gentoo/repositories.xml
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
sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.froxlor.org-froxlor.gpg] https://deb.froxlor.org/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/froxlor.list'
```
## Contributing ## Contributing

View File

@@ -1,14 +0,0 @@
# Security Policy
## Supported Versions
Our main and active version is currently 0.10.x. It will receive maintenance and security updates periodically. The older version 0.9.x will not receive any kind of updates. Please update to [0.10.x](https://github.com/Froxlor/Froxlor/wiki/Updating-Froxlor)
| Version | Supported |
| ------- | ------------------ |
| 0.10.x | :white_check_mark: |
| 0.9.x | :x: |
## Reporting a Vulnerability
If you think you have found a vulnerability in froxlor, please send an email to [team@froxlor.org](mailto:team@froxlor.org) with as many information as possible. Also, please give us appropriate time to fix the issue and build update-packages before publishing anything into the wild.

View File

@@ -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
*
*/
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

@@ -16,42 +16,31 @@
* @package Language * @package Language
* *
*/ */
return array( return array(
'groups' => array( 'groups' => array(
'panel' => array( 'panel' => array(
'title' => $lng['admin']['panelsettings'], 'title' => $lng['admin']['panelsettings'],
'fields' => array( 'fields' => array(
'panel_standardlanguage' => array( 'panel_standardlanguage' => array(
'label' => array( 'label' => array('title' => $lng['login']['language'], 'description' => $lng['serversettings']['language']['description']),
'title' => $lng['login']['language'],
'description' => $lng['serversettings']['language']['description']
),
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'standardlanguage', 'varname' => 'standardlanguage',
'type' => 'option', 'type' => 'option',
'default' => 'English', 'default' => 'English',
'option_mode' => 'one', 'option_mode' => 'one',
'option_options_method' => array( 'option_options_method' => 'getLanguages',
'\\Froxlor\\User', 'save_method' => 'storeSettingField',
'getLanguages'
),
'save_method' => 'storeSettingField'
), ),
'panel_default_theme' => array( 'panel_default_theme' => array(
'label' => array( 'label' => array('title' => $lng['panel']['theme'], 'description' => $lng['serversettings']['default_theme']),
'title' => $lng['panel']['theme'],
'description' => $lng['serversettings']['default_theme']
),
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'default_theme', 'varname' => 'default_theme',
'type' => 'option', 'type' => 'option',
'default' => 'Sparkle', 'default' => 'Froxlor',
'option_mode' => 'one', 'option_mode' => 'one',
'option_options_method' => array( 'option_options_method' => 'getThemes',
'\\Froxlor\\UI\\Template', 'save_method' => 'storeSettingDefaultTheme',
'getThemes'
),
'save_method' => 'storeSettingDefaultTheme'
), ),
'panel_allow_theme_change_customer' => array( 'panel_allow_theme_change_customer' => array(
'label' => $lng['serversettings']['panel_allow_theme_change_customer'], 'label' => $lng['serversettings']['panel_allow_theme_change_customer'],
@@ -59,7 +48,7 @@ return array(
'varname' => 'allow_theme_change_customer', 'varname' => 'allow_theme_change_customer',
'type' => 'bool', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'panel_allow_theme_change_admin' => array( 'panel_allow_theme_change_admin' => array(
'label' => $lng['serversettings']['panel_allow_theme_change_admin'], 'label' => $lng['serversettings']['panel_allow_theme_change_admin'],
@@ -75,7 +64,15 @@ return array(
'varname' => 'natsorting', 'varname' => 'natsorting',
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
),
'panel_no_robots' => array(
'label' => $lng['serversettings']['no_robots'],
'settinggroup' => 'panel',
'varname' => 'no_robots',
'type' => 'bool',
'default' => true,
'save_method' => 'storeSettingField',
), ),
'panel_paging' => array( 'panel_paging' => array(
'label' => $lng['serversettings']['paging'], 'label' => $lng['serversettings']['paging'],
@@ -84,7 +81,7 @@ return array(
'type' => 'int', 'type' => 'int',
'int_min' => 0, 'int_min' => 0,
'default' => 0, 'default' => 0,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'panel_pathedit' => array( 'panel_pathedit' => array(
'label' => $lng['serversettings']['pathedit'], 'label' => $lng['serversettings']['pathedit'],
@@ -93,11 +90,8 @@ return array(
'type' => 'option', 'type' => 'option',
'default' => 'Manual', 'default' => 'Manual',
'option_mode' => 'one', 'option_mode' => 'one',
'option_options' => array( 'option_options' => array('Manual' => $lng['serversettings']['manual'], 'Dropdown' => $lng['serversettings']['dropdown']),
'Manual' => $lng['serversettings']['manual'], 'save_method' => 'storeSettingField',
'Dropdown' => $lng['serversettings']['dropdown']
),
'save_method' => 'storeSettingField'
), ),
'panel_adminmail' => array( 'panel_adminmail' => array(
'label' => $lng['serversettings']['adminmail'], 'label' => $lng['serversettings']['adminmail'],
@@ -107,7 +101,7 @@ return array(
'string_type' => 'mail', 'string_type' => 'mail',
'string_emptyallowed' => false, 'string_emptyallowed' => false,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'panel_adminmail_defname' => array( 'panel_adminmail_defname' => array(
'label' => $lng['serversettings']['adminmail_defname'], 'label' => $lng['serversettings']['adminmail_defname'],
@@ -115,7 +109,7 @@ return array(
'varname' => 'adminmail_defname', 'varname' => 'adminmail_defname',
'type' => 'string', 'type' => 'string',
'default' => 'Froxlor Administrator', 'default' => 'Froxlor Administrator',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'panel_adminmail_return' => array( 'panel_adminmail_return' => array(
'label' => $lng['serversettings']['adminmail_return'], 'label' => $lng['serversettings']['adminmail_return'],
@@ -125,7 +119,7 @@ return array(
'string_type' => 'mail', 'string_type' => 'mail',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'panel_decimal_places' => array( 'panel_decimal_places' => array(
'label' => $lng['serversettings']['decimal_places'], 'label' => $lng['serversettings']['decimal_places'],
@@ -135,7 +129,7 @@ return array(
'int_min' => 0, 'int_min' => 0,
'int_max' => 15, 'int_max' => 15,
'default' => 4, 'default' => 4,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'panel_phpmyadmin_url' => array( 'panel_phpmyadmin_url' => array(
'label' => $lng['serversettings']['phpmyadmin_url'], 'label' => $lng['serversettings']['phpmyadmin_url'],
@@ -145,7 +139,7 @@ return array(
'string_type' => 'url', 'string_type' => 'url',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'panel_webmail_url' => array( 'panel_webmail_url' => array(
'label' => $lng['serversettings']['webmail_url'], 'label' => $lng['serversettings']['webmail_url'],
@@ -155,7 +149,7 @@ return array(
'string_type' => 'url', 'string_type' => 'url',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'panel_webftp_url' => array( 'panel_webftp_url' => array(
'label' => $lng['serversettings']['webftp_url'], 'label' => $lng['serversettings']['webftp_url'],
@@ -165,7 +159,7 @@ return array(
'string_type' => 'url', 'string_type' => 'url',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'admin_show_version_login' => array( 'admin_show_version_login' => array(
'label' => $lng['admin']['show_version_login'], 'label' => $lng['admin']['show_version_login'],
@@ -173,7 +167,7 @@ return array(
'varname' => 'show_version_login', 'varname' => 'show_version_login',
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'admin_show_version_footer' => array( 'admin_show_version_footer' => array(
'label' => $lng['admin']['show_version_footer'], 'label' => $lng['admin']['show_version_footer'],
@@ -181,7 +175,7 @@ return array(
'varname' => 'show_version_footer', 'varname' => 'show_version_footer',
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'admin_show_news_feed' => array( 'admin_show_news_feed' => array(
'label' => $lng['admin']['show_news_feed'], 'label' => $lng['admin']['show_news_feed'],
@@ -189,7 +183,7 @@ return array(
'varname' => 'show_news_feed', 'varname' => 'show_news_feed',
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'customer_show_news_feed' => array( 'customer_show_news_feed' => array(
'label' => $lng['admin']['customer_show_news_feed'], 'label' => $lng['admin']['customer_show_news_feed'],
@@ -197,7 +191,7 @@ return array(
'varname' => 'show_news_feed', 'varname' => 'show_news_feed',
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'customer_news_feed_url' => array( 'customer_news_feed_url' => array(
'label' => $lng['admin']['customer_news_feed_url'], 'label' => $lng['admin']['customer_news_feed_url'],
@@ -207,7 +201,7 @@ return array(
'string_type' => 'url', 'string_type' => 'url',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'panel_allow_domain_change_admin' => array( 'panel_allow_domain_change_admin' => array(
'label' => $lng['serversettings']['panel_allow_domain_change_admin'], 'label' => $lng['serversettings']['panel_allow_domain_change_admin'],
@@ -215,7 +209,7 @@ return array(
'varname' => 'allow_domain_change_admin', 'varname' => 'allow_domain_change_admin',
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'panel_allow_domain_change_customer' => array( 'panel_allow_domain_change_customer' => array(
'label' => $lng['serversettings']['panel_allow_domain_change_customer'], 'label' => $lng['serversettings']['panel_allow_domain_change_customer'],
@@ -223,7 +217,7 @@ return array(
'varname' => 'allow_domain_change_customer', 'varname' => 'allow_domain_change_customer',
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'panel_phpconfigs_hidestdsubdomain' => array( 'panel_phpconfigs_hidestdsubdomain' => array(
'label' => $lng['serversettings']['panel_phpconfigs_hidestdsubdomain'], 'label' => $lng['serversettings']['panel_phpconfigs_hidestdsubdomain'],
@@ -231,7 +225,7 @@ return array(
'varname' => 'phpconfigs_hidestdsubdomain', 'varname' => 'phpconfigs_hidestdsubdomain',
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'panel_customer_hide_options' => array( 'panel_customer_hide_options' => array(
'label' => $lng['serversettings']['panel_customer_hide_options'], 'label' => $lng['serversettings']['panel_customer_hide_options'],
@@ -249,82 +243,18 @@ return array(
'extras' => $lng['menue']['extras']['extras'], 'extras' => $lng['menue']['extras']['extras'],
'extras.directoryprotection' => $lng['menue']['extras']['extras']." / ".$lng['menue']['extras']['directoryprotection'], 'extras.directoryprotection' => $lng['menue']['extras']['extras']." / ".$lng['menue']['extras']['directoryprotection'],
'extras.pathoptions' => $lng['menue']['extras']['extras']." / ".$lng['menue']['extras']['pathoptions'], 'extras.pathoptions' => $lng['menue']['extras']['extras']." / ".$lng['menue']['extras']['pathoptions'],
'extras.logger' => $lng['menue']['extras']['extras'] . " / " . $lng['admin']['loggersystem'], 'extras.logger' => $lng['menue']['extras']['extras']." / ".$lng['menue']['logger']['logger'],
'extras.backup' => $lng['menue']['extras']['extras']." / ".$lng['menue']['extras']['backup'], 'extras.backup' => $lng['menue']['extras']['extras']." / ".$lng['menue']['extras']['backup'],
'traffic' => $lng['menue']['traffic']['traffic'], 'traffic' => $lng['menue']['traffic']['traffic'],
'traffic.http' => $lng['menue']['traffic']['traffic']." / HTTP", 'traffic.http' => $lng['menue']['traffic']['traffic']." / HTTP",
'traffic.ftp' => $lng['menue']['traffic']['traffic']." / FTP", 'traffic.ftp' => $lng['menue']['traffic']['traffic']." / FTP",
'traffic.mail' => $lng['menue']['traffic']['traffic'] . " / Mail" 'traffic.mail' => $lng['menue']['traffic']['traffic']." / Mail",
), ),
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'panel_imprint_url' => array(
'label' => $lng['serversettings']['imprint_url'],
'settinggroup' => 'panel',
'varname' => 'imprint_url',
'type' => 'string',
'string_type' => 'url',
'string_emptyallowed' => true,
'default' => '',
'save_method' => 'storeSettingField'
), ),
'panel_terms_url' => array(
'label' => $lng['serversettings']['terms_url'],
'settinggroup' => 'panel',
'varname' => 'terms_url',
'type' => 'string',
'string_type' => 'url',
'string_emptyallowed' => true,
'default' => '',
'save_method' => 'storeSettingField'
), ),
'panel_privacy_url' => array(
'label' => $lng['serversettings']['privacy_url'],
'settinggroup' => 'panel',
'varname' => 'privacy_url',
'type' => 'string',
'string_type' => 'url',
'string_emptyallowed' => true,
'default' => '',
'save_method' => 'storeSettingField'
), ),
'panel_logo_overridetheme' => array(
'label' => $lng['serversettings']['logo_overridetheme'],
'settinggroup' => 'panel',
'varname' => 'logo_overridetheme',
'type' => 'bool',
'default' => false,
'save_method' => 'storeSettingField'
),
'panel_logo_overridecustom' => array(
'label' => $lng['serversettings']['logo_overridecustom'],
'settinggroup' => 'panel',
'varname' => 'logo_overridecustom',
'type' => 'bool',
'default' => false,
'save_method' => 'storeSettingField'
),
'panel_logo_image_header' => array(
'label' => $lng['serversettings']['logo_image_header'],
'settinggroup' => 'panel',
'varname' => 'logo_image_header',
'type' => 'image',
'image_name' => 'logo_header',
'default' => '',
'save_method' => 'storeSettingImage'
),
'panel_logo_image_login' => array(
'label' => $lng['serversettings']['logo_image_login'],
'settinggroup' => 'panel',
'varname' => 'logo_image_login',
'type' => 'image',
'image_name' => 'logo_login',
'default' => '',
'save_method' => 'storeSettingImage'
),
)
)
)
); );
?> ?>

View File

@@ -16,6 +16,7 @@
* @package Settings * @package Settings
* *
*/ */
return array( return array(
'groups' => array( 'groups' => array(
'accounts' => array( 'accounts' => array(
@@ -27,7 +28,7 @@ return array(
'varname' => 'sessiontimeout', 'varname' => 'sessiontimeout',
'type' => 'int', 'type' => 'int',
'default' => 600, 'default' => 600,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'session_allow_multiple_login' => array( 'session_allow_multiple_login' => array(
'label' => $lng['serversettings']['session_allow_multiple_login'], 'label' => $lng['serversettings']['session_allow_multiple_login'],
@@ -35,7 +36,7 @@ return array(
'varname' => 'allow_multiple_login', 'varname' => 'allow_multiple_login',
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'login_domain_login' => array( 'login_domain_login' => array(
'label' => $lng['serversettings']['login_domain_login'], 'label' => $lng['serversettings']['login_domain_login'],
@@ -43,7 +44,7 @@ return array(
'varname' => 'domain_login', 'varname' => 'domain_login',
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'login_maxloginattempts' => array( 'login_maxloginattempts' => array(
'label' => $lng['serversettings']['maxloginattempts'], 'label' => $lng['serversettings']['maxloginattempts'],
@@ -51,7 +52,7 @@ return array(
'varname' => 'maxloginattempts', 'varname' => 'maxloginattempts',
'type' => 'int', 'type' => 'int',
'default' => 3, 'default' => 3,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'login_deactivatetime' => array( 'login_deactivatetime' => array(
'label' => $lng['serversettings']['deactivatetime'], 'label' => $lng['serversettings']['deactivatetime'],
@@ -59,15 +60,7 @@ return array(
'varname' => 'deactivatetime', 'varname' => 'deactivatetime',
'type' => 'int', 'type' => 'int',
'default' => 900, 'default' => 900,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
),
'2fa_enabled' => array(
'label' => $lng['2fa']['2fa_enabled'],
'settinggroup' => '2fa',
'varname' => 'enabled',
'type' => 'bool',
'default' => true,
'save_method' => 'storeSettingField'
), ),
'panel_password_min_length' => array( 'panel_password_min_length' => array(
'label' => $lng['serversettings']['panel_password_min_length'], 'label' => $lng['serversettings']['panel_password_min_length'],
@@ -75,7 +68,7 @@ return array(
'varname' => 'password_min_length', 'varname' => 'password_min_length',
'type' => 'int', 'type' => 'int',
'default' => 0, 'default' => 0,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'panel_password_alpha_lower' => array( 'panel_password_alpha_lower' => array(
'label' => $lng['serversettings']['panel_password_alpha_lower'], 'label' => $lng['serversettings']['panel_password_alpha_lower'],
@@ -83,7 +76,7 @@ return array(
'varname' => 'password_alpha_lower', 'varname' => 'password_alpha_lower',
'type' => 'bool', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'panel_password_alpha_upper' => array( 'panel_password_alpha_upper' => array(
'label' => $lng['serversettings']['panel_password_alpha_upper'], 'label' => $lng['serversettings']['panel_password_alpha_upper'],
@@ -91,7 +84,7 @@ return array(
'varname' => 'password_alpha_upper', 'varname' => 'password_alpha_upper',
'type' => 'bool', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'panel_password_numeric' => array( 'panel_password_numeric' => array(
'label' => $lng['serversettings']['panel_password_numeric'], 'label' => $lng['serversettings']['panel_password_numeric'],
@@ -99,7 +92,7 @@ return array(
'varname' => 'password_numeric', 'varname' => 'password_numeric',
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'panel_password_special_char_required' => array( 'panel_password_special_char_required' => array(
'label' => $lng['serversettings']['panel_password_special_char_required'], 'label' => $lng['serversettings']['panel_password_special_char_required'],
@@ -107,7 +100,7 @@ return array(
'varname' => 'password_special_char_required', 'varname' => 'password_special_char_required',
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'panel_password_special_char' => array( 'panel_password_special_char' => array(
'label' => $lng['serversettings']['panel_password_special_char'], 'label' => $lng['serversettings']['panel_password_special_char'],
@@ -115,7 +108,7 @@ return array(
'varname' => 'password_special_char', 'varname' => 'password_special_char',
'type' => 'string', 'type' => 'string',
'default' => '!?<>§$%+#=@', 'default' => '!?<>§$%+#=@',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'panel_password_regex' => array( 'panel_password_regex' => array(
'label' => $lng['serversettings']['panel_password_regex'], 'label' => $lng['serversettings']['panel_password_regex'],
@@ -123,7 +116,8 @@ return array(
'varname' => 'password_regex', 'varname' => 'password_regex',
'type' => 'string', 'type' => 'string',
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' /* 'plausibility_check_method' => 'checkValidRegEx', */
'save_method' => 'storeSettingField',
), ),
'customer_accountprefix' => array( 'customer_accountprefix' => array(
'label' => $lng['serversettings']['accountprefix'], 'label' => $lng['serversettings']['accountprefix'],
@@ -131,11 +125,8 @@ return array(
'varname' => 'accountprefix', 'varname' => 'accountprefix',
'type' => 'string', 'type' => 'string',
'default' => '', 'default' => '',
'plausibility_check_method' => array( 'plausibility_check_method' => 'checkUsername',
'\\Froxlor\\Validate\\Check', 'save_method' => 'storeSettingField',
'checkUsername'
),
'save_method' => 'storeSettingField'
), ),
'customer_mysqlprefix' => array( 'customer_mysqlprefix' => array(
'label' => $lng['serversettings']['mysqlprefix'], 'label' => $lng['serversettings']['mysqlprefix'],
@@ -143,11 +134,8 @@ return array(
'varname' => 'mysqlprefix', 'varname' => 'mysqlprefix',
'type' => 'string', 'type' => 'string',
'default' => '', 'default' => '',
'plausibility_check_method' => array( 'plausibility_check_method' => 'checkUsername',
'\\Froxlor\\Validate\\Check', 'save_method' => 'storeSettingField',
'checkUsername'
),
'save_method' => 'storeSettingField'
), ),
'customer_ftpprefix' => array( 'customer_ftpprefix' => array(
'label' => $lng['serversettings']['ftpprefix'], 'label' => $lng['serversettings']['ftpprefix'],
@@ -155,7 +143,7 @@ return array(
'varname' => 'ftpprefix', 'varname' => 'ftpprefix',
'type' => 'string', 'type' => 'string',
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'customer_ftpatdomain' => array( 'customer_ftpatdomain' => array(
'label' => $lng['serversettings']['ftpdomain'], 'label' => $lng['serversettings']['ftpdomain'],
@@ -163,7 +151,7 @@ return array(
'varname' => 'ftpatdomain', 'varname' => 'ftpatdomain',
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'panel_allow_preset' => array( 'panel_allow_preset' => array(
'label' => $lng['serversettings']['allow_password_reset'], 'label' => $lng['serversettings']['allow_password_reset'],
@@ -176,7 +164,7 @@ return array(
'fieldname' => 'panel_allow_preset_admin', 'fieldname' => 'panel_allow_preset_admin',
'fielddata' => array( 'fielddata' => array(
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'allow_preset_admin' 'varname' => 'allow_preset_admin',
), ),
'onlyif' => 0 'onlyif' => 0
) )
@@ -192,7 +180,7 @@ return array(
'fieldname' => 'panel_allow_preset', 'fieldname' => 'panel_allow_preset',
'fielddata' => array( 'fielddata' => array(
'settinggroup' => 'panel', 'settinggroup' => 'panel',
'varname' => 'allow_preset' 'varname' => 'allow_preset',
), ),
'onlyif' => 1 'onlyif' => 1
) )
@@ -206,20 +194,8 @@ return array(
'cronmodule' => 'froxlor/backup', 'cronmodule' => 'froxlor/backup',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
), ),
'system_createstdsubdom_default' => array(
'label' => $lng['serversettings']['createstdsubdom_default'],
'settinggroup' => 'system',
'varname' => 'createstdsubdom_default',
'type' => 'option',
'default' => '1',
'option_mode' => 'one',
'option_options' => array(
'0' => $lng['panel']['no'],
'1' => $lng['panel']['yes']
), ),
'save_method' => 'storeSettingField'
), ),
) )
)
)
); );

View File

@@ -16,6 +16,7 @@
* @package Settings * @package Settings
* *
*/ */
return array( return array(
'groups' => array( 'groups' => array(
'system' => array( 'system' => array(
@@ -29,10 +30,7 @@ return array(
'string_type' => 'dir', 'string_type' => 'dir',
'default' => '/var/customers/webs/', 'default' => '/var/customers/webs/',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'plausibility_check_method' => array( 'plausibility_check_method' => 'checkPathConflicts'
'\\Froxlor\\Validate\\Check',
'checkPathConflicts'
)
), ),
'system_documentroot_use_default_value' => array( 'system_documentroot_use_default_value' => array(
'label' => $lng['serversettings']['documentroot_use_default_value'], 'label' => $lng['serversettings']['documentroot_use_default_value'],
@@ -40,7 +38,7 @@ return array(
'varname' => 'documentroot_use_default_value', 'varname' => 'documentroot_use_default_value',
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_ipaddress' => array( 'system_ipaddress' => array(
'label' => $lng['serversettings']['ipaddress'], 'label' => $lng['serversettings']['ipaddress'],
@@ -48,12 +46,9 @@ return array(
'varname' => 'ipaddress', 'varname' => 'ipaddress',
'type' => 'option', 'type' => 'option',
'option_mode' => 'one', 'option_mode' => 'one',
'option_options_method' => array( 'option_options_method' => 'getIpAddresses',
'\\Froxlor\\Domain\\IpAddr',
'getIpAddresses'
),
'default' => '', 'default' => '',
'save_method' => 'storeSettingIpAddress' 'save_method' => 'storeSettingIpAddress',
), ),
'system_defaultip' => array( 'system_defaultip' => array(
'label' => $lng['serversettings']['defaultip'], 'label' => $lng['serversettings']['defaultip'],
@@ -61,25 +56,9 @@ return array(
'varname' => 'defaultip', 'varname' => 'defaultip',
'type' => 'option', 'type' => 'option',
'option_mode' => 'multiple', 'option_mode' => 'multiple',
'option_options_method' => array( 'option_options_method' => 'getIpPortCombinations',
'\\Froxlor\\Domain\\IpAddr',
'getIpPortCombinations'
),
'default' => '', 'default' => '',
'save_method' => 'storeSettingDefaultIp' 'save_method' => 'storeSettingDefaultIp',
),
'system_defaultsslip' => array(
'label' => $lng['serversettings']['defaultsslip'],
'settinggroup' => 'system',
'varname' => 'defaultsslip',
'type' => 'option',
'option_mode' => 'multiple',
'option_options_method' => array(
'\\Froxlor\\Domain\\IpAddr',
'getSslIpPortCombinations'
),
'default' => '',
'save_method' => 'storeSettingDefaultSslIp'
), ),
'system_hostname' => array( 'system_hostname' => array(
'label' => $lng['serversettings']['hostname'], 'label' => $lng['serversettings']['hostname'],
@@ -88,18 +67,7 @@ return array(
'type' => 'string', 'type' => 'string',
'default' => '', 'default' => '',
'save_method' => 'storeSettingHostname', 'save_method' => 'storeSettingHostname',
'plausibility_check_method' => array( 'plausibility_check_method' => 'checkHostname',
'\\Froxlor\\Validate\\Check',
'checkHostname'
)
),
'api_enabled' => array(
'label' => $lng['serversettings']['enable_api'],
'settinggroup' => 'api',
'varname' => 'enabled',
'type' => 'bool',
'default' => false,
'save_method' => 'storeSettingField'
), ),
'system_validatedomain' => array( 'system_validatedomain' => array(
'label' => $lng['serversettings']['validate_domain'], 'label' => $lng['serversettings']['validate_domain'],
@@ -107,7 +75,7 @@ return array(
'varname' => 'validate_domain', 'varname' => 'validate_domain',
'type' => 'bool', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_stdsubdomain' => array( 'system_stdsubdomain' => array(
'label' => $lng['serversettings']['stdsubdomainhost'], 'label' => $lng['serversettings']['stdsubdomainhost'],
@@ -115,7 +83,7 @@ return array(
'varname' => 'stdsubdomain', 'varname' => 'stdsubdomain',
'type' => 'string', 'type' => 'string',
'default' => '', 'default' => '',
'save_method' => 'storeSettingHostname' 'save_method' => 'storeSettingHostname',
), ),
'system_mysql_access_host' => array( 'system_mysql_access_host' => array(
'label' => $lng['serversettings']['mysql_access_host'], 'label' => $lng['serversettings']['mysql_access_host'],
@@ -123,11 +91,8 @@ return array(
'varname' => 'mysql_access_host', 'varname' => 'mysql_access_host',
'type' => 'string', 'type' => 'string',
'default' => '127.0.0.1,localhost', 'default' => '127.0.0.1,localhost',
'plausibility_check_method' => array( 'plausibility_check_method' => 'checkMysqlAccessHost',
'\\Froxlor\\Validate\\Check', 'save_method' => 'storeSettingMysqlAccessHost',
'checkMysqlAccessHost'
),
'save_method' => 'storeSettingMysqlAccessHost'
), ),
'system_nssextrausers' => array( 'system_nssextrausers' => array(
'label' => $lng['serversettings']['nssextrausers'], 'label' => $lng['serversettings']['nssextrausers'],
@@ -144,7 +109,7 @@ return array(
'type' => 'string', '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',
), ),
'system_store_index_file_subs' => array( 'system_store_index_file_subs' => array(
'label' => $lng['serversettings']['system_store_index_file_subs'], 'label' => $lng['serversettings']['system_store_index_file_subs'],
@@ -152,19 +117,19 @@ return array(
'varname' => 'store_index_file_subs', 'varname' => 'store_index_file_subs',
'type' => 'bool', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_httpuser' => array( 'system_httpuser' => array(
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'httpuser', 'varname' => 'httpuser',
'type' => 'hidden', 'type' => 'hidden',
'default' => 'www-data' 'default' => 'www-data',
), ),
'system_httpgroup' => array( 'system_httpgroup' => array(
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'httpgroup', 'varname' => 'httpgroup',
'type' => 'hidden', 'type' => 'hidden',
'default' => 'www-data' 'default' => 'www-data',
), ),
'system_report_enable' => array( 'system_report_enable' => array(
'label' => $lng['serversettings']['report']['report'], 'label' => $lng['serversettings']['report']['report'],
@@ -173,7 +138,7 @@ return array(
'type' => 'bool', 'type' => 'bool',
'default' => true, 'default' => true,
'cronmodule' => 'froxlor/reports', 'cronmodule' => 'froxlor/reports',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_report_webmax' => array( 'system_report_webmax' => array(
'label' => $lng['serversettings']['report']['webmax'], 'label' => $lng['serversettings']['report']['webmax'],
@@ -183,7 +148,7 @@ return array(
'int_min' => 0, 'int_min' => 0,
'int_max' => 150, 'int_max' => 150,
'default' => 90, 'default' => 90,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_report_trafficmax' => array( 'system_report_trafficmax' => array(
'label' => $lng['serversettings']['report']['trafficmax'], 'label' => $lng['serversettings']['report']['trafficmax'],
@@ -193,7 +158,7 @@ return array(
'int_min' => 0, 'int_min' => 0,
'int_max' => 150, 'int_max' => 150,
'default' => 90, 'default' => 90,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_mail_use_smtp' => array( 'system_mail_use_smtp' => array(
@@ -202,7 +167,7 @@ return array(
'varname' => 'mail_use_smtp', 'varname' => 'mail_use_smtp',
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_mail_smtp_host' => array( 'system_mail_smtp_host' => array(
'label' => $lng['serversettings']['mail_smtp_host'], 'label' => $lng['serversettings']['mail_smtp_host'],
@@ -210,7 +175,7 @@ return array(
'varname' => 'mail_smtp_host', 'varname' => 'mail_smtp_host',
'type' => 'string', 'type' => 'string',
'default' => 'localhost', 'default' => 'localhost',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_mail_smtp_port' => array( 'system_mail_smtp_port' => array(
'label' => $lng['serversettings']['mail_smtp_port'], 'label' => $lng['serversettings']['mail_smtp_port'],
@@ -220,7 +185,7 @@ return array(
'int_min' => 1, 'int_min' => 1,
'int_max' => 65535, 'int_max' => 65535,
'default' => 25, 'default' => 25,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_mail_smtp_usetls' => array( 'system_mail_smtp_usetls' => array(
'label' => $lng['serversettings']['mail_smtp_usetls'], 'label' => $lng['serversettings']['mail_smtp_usetls'],
@@ -228,7 +193,7 @@ return array(
'varname' => 'mail_smtp_usetls', 'varname' => 'mail_smtp_usetls',
'type' => 'bool', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_mail_smtp_auth' => array( 'system_mail_smtp_auth' => array(
'label' => $lng['serversettings']['mail_smtp_auth'], 'label' => $lng['serversettings']['mail_smtp_auth'],
@@ -236,7 +201,7 @@ return array(
'varname' => 'mail_smtp_auth', 'varname' => 'mail_smtp_auth',
'type' => 'bool', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_mail_smtp_user' => array( 'system_mail_smtp_user' => array(
'label' => $lng['serversettings']['mail_smtp_user'], 'label' => $lng['serversettings']['mail_smtp_user'],
@@ -244,7 +209,7 @@ return array(
'varname' => 'mail_smtp_user', 'varname' => 'mail_smtp_user',
'type' => 'string', 'type' => 'string',
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_mail_smtp_passwd' => array( 'system_mail_smtp_passwd' => array(
'label' => $lng['serversettings']['mail_smtp_passwd'], 'label' => $lng['serversettings']['mail_smtp_passwd'],
@@ -252,47 +217,9 @@ return array(
'varname' => 'mail_smtp_passwd', 'varname' => 'mail_smtp_passwd',
'type' => 'hiddenString', 'type' => 'hiddenString',
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_apply_specialsettings_default' => array(
'label' => $lng['serversettings']['apply_specialsettings_default'],
'settinggroup' => 'system',
'varname' => 'apply_specialsettings_default',
'type' => 'bool',
'default' => true,
'save_method' => 'storeSettingField'
), ),
'system_apply_phpconfigs_default' => array(
'label' => $lng['serversettings']['apply_phpconfigs_default'],
'settinggroup' => 'system',
'varname' => 'apply_phpconfigs_default',
'type' => 'bool',
'default' => true,
'save_method' => 'storeSettingField'
), ),
'system_domaindefaultalias' => array(
'label' => $lng['admin']['domaindefaultalias'],
'settinggroup' => 'system',
'varname' => 'domaindefaultalias',
'type' => 'option',
'default' => '0',
'option_mode' => 'one',
'option_options' => array(
'0' => $lng['domains']['serveraliasoption_wildcard'],
'1' => $lng['domains']['serveraliasoption_www'],
'2' => $lng['domains']['serveraliasoption_none']
), ),
'save_method' => 'storeSettingField'
),
'hide_incompatible_settings' => array(
'label' => $lng['serversettings']['hide_incompatible_settings'],
'settinggroup' => 'system',
'varname' => 'hide_incompatible_settings',
'type' => 'bool',
'default' => false,
'save_method' => 'storeSettingField'
),
)
)
)
); );

View File

@@ -11,13 +11,13 @@
* @copyright (c) the authors * @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2016-) * @author Froxlor team <team@froxlor.org> (2016-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package \Froxlor\Settings * @package Settings
* *
*/ */
return array( return array(
'groups' => array( 'groups' => array(
'froxlorvhost' => array( 'froxlorvhost' => array(
'title' => $lng['admin']['froxlorvhost'] . (call_user_func(array('\Froxlor\Settings\FroxlorVhostSettings', 'hasVhostContainerEnabled')) == false ? $lng['admin']['novhostcontainer'] : ''), 'title' => $lng['admin']['froxlorvhost'],
'fields' => array( 'fields' => array(
/** /**
* Webserver-Vhost * Webserver-Vhost
@@ -30,16 +30,6 @@ return array(
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
), ),
'system_froxloraliases' => array(
'label' => $lng['serversettings']['froxloraliases'],
'settinggroup' => 'system',
'varname' => 'froxloraliases',
'type' => 'string',
'string_regexp' => '/^(([a-z0-9\-\._]+, ?)*[a-z0-9\-\._]+)?$/i',
'string_emptyallowed' => true,
'default' => '',
'save_method' => 'storeSettingField'
),
/** /**
* SSL / Let's Encrypt * SSL / Let's Encrypt
*/ */
@@ -50,10 +40,7 @@ return array(
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingClearCertificates', 'save_method' => 'storeSettingClearCertificates',
'visible' => \Froxlor\Settings::Get('system.leenabled') && call_user_func(array( 'visible' => Settings::Get('system.leenabled')
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
), true)
), ),
'system_le_froxlor_redirect' => array( 'system_le_froxlor_redirect' => array(
'label' => $lng['serversettings']['le_froxlor_redirect'], 'label' => $lng['serversettings']['le_froxlor_redirect'],
@@ -62,10 +49,7 @@ return array(
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => \Froxlor\Settings::Get('system.use_ssl') && call_user_func(array( 'visible' => Settings::Get('system.use_ssl')
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
), true)
), ),
'system_hsts_maxage' => array( 'system_hsts_maxage' => array(
'label' => $lng['admin']['domain_hsts_maxage'], 'label' => $lng['admin']['domain_hsts_maxage'],
@@ -76,10 +60,7 @@ return array(
'int_max' => 94608000, // 3-years 'int_max' => 94608000, // 3-years
'default' => 0, 'default' => 0,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => \Froxlor\Settings::Get('system.use_ssl') && call_user_func(array( 'visible' => Settings::Get('system.use_ssl')
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
), true)
), ),
'system_hsts_incsub' => array( 'system_hsts_incsub' => array(
'label' => $lng['admin']['domain_hsts_incsub'], 'label' => $lng['admin']['domain_hsts_incsub'],
@@ -88,10 +69,7 @@ return array(
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => \Froxlor\Settings::Get('system.use_ssl') && call_user_func(array( 'visible' => Settings::Get('system.use_ssl')
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
), true)
), ),
'system_hsts_preload' => array( 'system_hsts_preload' => array(
'label' => $lng['admin']['domain_hsts_preload'], 'label' => $lng['admin']['domain_hsts_preload'],
@@ -100,34 +78,7 @@ return array(
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => \Froxlor\Settings::Get('system.use_ssl') && call_user_func(array( 'visible' => Settings::Get('system.use_ssl')
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
), true)
),
'system_honorcipherorder' => array(
'label' => $lng['admin']['domain_honorcipherorder'],
'settinggroup' => 'system',
'varname' => 'honorcipherorder',
'type' => 'bool',
'default' => false,
'save_method' => 'storeSettingField',
'visible' => \Froxlor\Settings::Get('system.use_ssl') && call_user_func(array(
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
), true)
),
'system_sessiontickets' => array(
'label' => $lng['admin']['domain_sessiontickets'],
'settinggroup' => 'system',
'varname' => 'sessiontickets',
'type' => 'bool',
'default' => true,
'save_method' => 'storeSettingField',
'visible' => \Froxlor\Settings::Get('system.use_ssl') && call_user_func(array(
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
), true)
), ),
/** /**
* FCGID * FCGID
@@ -142,10 +93,7 @@ return array(
'websrv_avail' => array( 'websrv_avail' => array(
'apache2' 'apache2'
), ),
'visible' => \Froxlor\Settings::Get('system.mod_fcgid') && call_user_func(array( 'visible' => Settings::Get('system.mod_fcgid')
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
))
), ),
'system_mod_fcgid_httpuser' => array( 'system_mod_fcgid_httpuser' => array(
'label' => $lng['admin']['mod_fcgid_user'], 'label' => $lng['admin']['mod_fcgid_user'],
@@ -157,10 +105,7 @@ return array(
'websrv_avail' => array( 'websrv_avail' => array(
'apache2' 'apache2'
), ),
'visible' => \Froxlor\Settings::Get('system.mod_fcgid') && call_user_func(array( 'visible' => Settings::Get('system.mod_fcgid')
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
))
), ),
'system_mod_fcgid_httpgroup' => array( 'system_mod_fcgid_httpgroup' => array(
'label' => $lng['admin']['mod_fcgid_group'], 'label' => $lng['admin']['mod_fcgid_group'],
@@ -172,10 +117,7 @@ return array(
'websrv_avail' => array( 'websrv_avail' => array(
'apache2' 'apache2'
), ),
'visible' => \Froxlor\Settings::Get('system.mod_fcgid') && call_user_func(array( 'visible' => Settings::Get('system.mod_fcgid')
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
))
), ),
'system_mod_fcgid_defaultini_ownvhost' => array( 'system_mod_fcgid_defaultini_ownvhost' => array(
'label' => $lng['serversettings']['mod_fcgid']['defaultini_ownvhost'], 'label' => $lng['serversettings']['mod_fcgid']['defaultini_ownvhost'],
@@ -184,18 +126,12 @@ return array(
'type' => 'option', 'type' => 'option',
'default' => '2', 'default' => '2',
'option_mode' => 'one', 'option_mode' => 'one',
'option_options_method' => array( 'option_options_method' => 'getPhpConfigs',
'\\Froxlor\\Http\\PhpConfig',
'getPhpConfigs'
),
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => array( 'websrv_avail' => array(
'apache2' 'apache2'
), ),
'visible' => \Froxlor\Settings::Get('system.mod_fcgid') && call_user_func(array( 'visible' => Settings::Get('system.mod_fcgid')
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
))
), ),
/** /**
* php-fpm * php-fpm
@@ -207,10 +143,7 @@ return array(
'type' => 'bool', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => \Froxlor\Settings::Get('phpfpm.enabled') && call_user_func(array( 'visible' => Settings::Get('phpfpm.enabled')
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
))
), ),
'system_phpfpm_httpuser' => array( 'system_phpfpm_httpuser' => array(
'label' => $lng['phpfpm']['vhost_httpuser'], 'label' => $lng['phpfpm']['vhost_httpuser'],
@@ -219,10 +152,7 @@ return array(
'type' => 'string', 'type' => 'string',
'default' => 'froxlorlocal', 'default' => 'froxlorlocal',
'save_method' => 'storeSettingWebserverFcgidFpmUser', 'save_method' => 'storeSettingWebserverFcgidFpmUser',
'visible' => \Froxlor\Settings::Get('phpfpm.enabled') && call_user_func(array( 'visible' => Settings::Get('phpfpm.enabled')
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
))
), ),
'system_phpfpm_httpgroup' => array( 'system_phpfpm_httpgroup' => array(
'label' => $lng['phpfpm']['vhost_httpgroup'], 'label' => $lng['phpfpm']['vhost_httpgroup'],
@@ -231,10 +161,7 @@ return array(
'type' => 'string', 'type' => 'string',
'default' => 'froxlorlocal', 'default' => 'froxlorlocal',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => \Froxlor\Settings::Get('phpfpm.enabled') && call_user_func(array( 'visible' => Settings::Get('phpfpm.enabled')
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
))
), ),
'system_phpfpm_defaultini_ownvhost' => array( 'system_phpfpm_defaultini_ownvhost' => array(
'label' => $lng['serversettings']['mod_fcgid']['defaultini_ownvhost'], 'label' => $lng['serversettings']['mod_fcgid']['defaultini_ownvhost'],
@@ -243,15 +170,9 @@ return array(
'type' => 'option', 'type' => 'option',
'default' => '2', 'default' => '2',
'option_mode' => 'one', 'option_mode' => 'one',
'option_options_method' => array( 'option_options_method' => 'getPhpConfigs',
'\\Froxlor\\Http\\PhpConfig',
'getPhpConfigs'
),
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => \Froxlor\Settings::Get('phpfpm.enabled') && call_user_func(array( 'visible' => Settings::Get('phpfpm.enabled')
'\Froxlor\Settings\FroxlorVhostSettings',
'hasVhostContainerEnabled'
))
), ),
/** /**
* DNS * DNS
@@ -263,7 +184,7 @@ return array(
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => \Froxlor\Settings::Get('system.bind_enable') 'visible' => Settings::Get('system.bind_enable')
) )
) )
) )

View File

@@ -14,6 +14,7 @@
* @package Settings * @package Settings
* *
*/ */
return array( return array(
'groups' => array( 'groups' => array(
'crond' => array( 'crond' => array(
@@ -26,7 +27,7 @@ return array(
'type' => 'string', 'type' => 'string',
'string_type' => 'file', 'string_type' => 'file',
'default' => '/etc/cron.d/froxlor', 'default' => '/etc/cron.d/froxlor',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_croncmdline' => array( 'system_croncmdline' => array(
'label' => $lng['serversettings']['system_croncmdline'], 'label' => $lng['serversettings']['system_croncmdline'],
@@ -34,7 +35,7 @@ return array(
'varname' => 'croncmdline', 'varname' => 'croncmdline',
'type' => 'string', 'type' => 'string',
'default' => '/usr/bin/nice -n 5 /usr/bin/php -q', 'default' => '/usr/bin/nice -n 5 /usr/bin/php -q',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_crondreload' => array( 'system_crondreload' => array(
'label' => $lng['serversettings']['system_crondreload'], 'label' => $lng['serversettings']['system_crondreload'],
@@ -42,7 +43,7 @@ return array(
'varname' => 'crondreload', 'varname' => 'crondreload',
'type' => 'string', 'type' => 'string',
'default' => '/etc/init.d/cron reload', 'default' => '/etc/init.d/cron reload',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_cron_allowautoupdate' => array( 'system_cron_allowautoupdate' => array(
'label' => $lng['serversettings']['system_cron_allowautoupdate'], 'label' => $lng['serversettings']['system_cron_allowautoupdate'],
@@ -50,7 +51,7 @@ return array(
'varname' => 'cron_allowautoupdate', 'varname' => 'cron_allowautoupdate',
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_debug_cron' => array( 'system_debug_cron' => array(
'label' => $lng['serversettings']['cron']['debug'], 'label' => $lng['serversettings']['cron']['debug'],
@@ -58,7 +59,7 @@ return array(
'varname' => 'debug_cron', 'varname' => 'debug_cron',
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
) )
) )
) )

View File

@@ -13,7 +13,7 @@
* @author Florian Lippert <flo@syscp.org> (2003-2009) * @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-) * @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package \Froxlor\Settings * @package Settings
* *
*/ */
return array( return array(
@@ -34,10 +34,7 @@ return array(
'nginx' => 'Nginx' 'nginx' => 'Nginx'
), ),
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'plausibility_check_method' => array( 'plausibility_check_method' => 'checkPhpInterfaceSetting',
'\\Froxlor\\Validate\\Check',
'checkPhpInterfaceSetting'
),
'overview_option' => true 'overview_option' => true
), ),
'system_apache_24' => array( 'system_apache_24' => array(
@@ -58,7 +55,7 @@ return array(
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => (\Froxlor\Settings::Get('system.mod_fcgid') == 0 && \Froxlor\Settings::Get('phpfpm.enabled') == 0), 'visible' => (Settings::Get('system.mod_fcgid') == 0 && Settings::Get('phpfpm.enabled') == 0),
'websrv_avail' => array( 'websrv_avail' => array(
'apache2' 'apache2'
) )
@@ -74,18 +71,7 @@ return array(
'apache2', 'apache2',
'nginx' 'nginx'
), ),
'visible' => \Froxlor\Settings::Get('system.use_ssl') 'visible' => Settings::Get('system.use_ssl')
),
'system_dhparams_file' => array(
'label' => $lng['serversettings']['dhparams_file'],
'settinggroup' => 'system',
'varname' => 'dhparams_file',
'type' => 'string',
'string_type' => 'file',
'string_emptyallowed' => true,
'default' => '',
'save_method' => 'storeSettingField',
'visible' => \Froxlor\Settings::Get('system.use_ssl')
), ),
'system_httpuser' => array( 'system_httpuser' => array(
'label' => $lng['admin']['webserver_user'], 'label' => $lng['admin']['webserver_user'],
@@ -173,8 +159,7 @@ return array(
'websrv_avail' => array( 'websrv_avail' => array(
'apache2', 'apache2',
'nginx' 'nginx'
), )
'visible' => \Froxlor\Settings::Get('system.awstats_enabled') == 1
), ),
'system_logfiles_type' => array( 'system_logfiles_type' => array(
'label' => $lng['serversettings']['logfiles_type'], 'label' => $lng['serversettings']['logfiles_type'],
@@ -192,29 +177,6 @@ return array(
'apache2' 'apache2'
) )
), ),
'system_errorlog_level' => array(
'label' => $lng['serversettings']['errorlog_level'],
'settinggroup' => 'system',
'varname' => 'errorlog_level',
'type' => 'option',
'default' => (\Froxlor\Settings::Get('system.webserver') == 'nginx' ? 'error' : 'warn'),
'option_mode' => 'one',
'option_options' => array(
'emerg' => 'emerg',
'alert' => 'alert',
'crit' => 'crit',
'error' => 'error',
'warn' => 'warn',
'notice' => 'notice',
'info' => 'info',
'debug' => 'debug'
),
'save_method' => 'storeSettingField',
'websrv_avail' => array(
'apache2',
'nginx'
)
),
'system_customersslpath' => array( 'system_customersslpath' => array(
'label' => $lng['serversettings']['customerssl_directory'], 'label' => $lng['serversettings']['customerssl_directory'],
'settinggroup' => 'system', 'settinggroup' => 'system',
@@ -251,23 +213,6 @@ return array(
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
), ),
'system_default_sslvhostconf' => array(
'label' => $lng['serversettings']['default_sslvhostconf'],
'settinggroup' => 'system',
'varname' => 'default_sslvhostconf',
'type' => 'text',
'default' => '',
'save_method' => 'storeSettingField',
'visible' => \Froxlor\Settings::Get('system.use_ssl') == 1
),
'system_include_default_vhostconf' => array(
'label' => $lng['serversettings']['includedefault_sslvhostconf'],
'settinggroup' => 'system',
'varname' => 'include_default_vhostconf',
'type' => 'bool',
'default' => false,
'save_method' => 'storeSettingField'
),
'system_apache_globaldiropt' => array( 'system_apache_globaldiropt' => array(
'label' => $lng['serversettings']['apache_globaldiropt'], 'label' => $lng['serversettings']['apache_globaldiropt'],
'settinggroup' => 'system', 'settinggroup' => 'system',
@@ -275,7 +220,7 @@ return array(
'type' => 'text', 'type' => 'text',
'default' => '', 'default' => '',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => (\Froxlor\Settings::Get('system.mod_fcgid') == 0 && \Froxlor\Settings::Get('phpfpm.enabled') == 0), 'visible' => (Settings::Get('system.mod_fcgid') == 0 && Settings::Get('phpfpm.enabled') == 0),
'websrv_avail' => array( 'websrv_avail' => array(
'apache2' 'apache2'
) )
@@ -389,7 +334,7 @@ return array(
'type' => 'option', 'type' => 'option',
'default' => '1', 'default' => '1',
'option_mode' => 'one', 'option_mode' => 'one',
'option_options_method' => array('\\Froxlor\\Domain\\Domain', 'getRedirectCodes'), 'option_options_method' => 'getRedirectCodes',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
) )
) )

View File

@@ -13,7 +13,7 @@
* @author Florian Lippert <flo@syscp.org> (2003-2009) * @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-) * @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package \Froxlor\Settings * @package Settings
* *
*/ */
return array( return array(
@@ -35,7 +35,7 @@ return array(
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'ssl_protocols', 'varname' => 'ssl_protocols',
'type' => 'option', 'type' => 'option',
'default' => 'TLSv1.2', 'default' => 'TLSv1,TLSv1.2',
'option_mode' => 'multiple', 'option_mode' => 'multiple',
'option_options' => array( 'option_options' => array(
'TLSv1' => 'TLSv1', 'TLSv1' => 'TLSv1',
@@ -54,16 +54,6 @@ return array(
'default' => 'ECDH+AESGCM:ECDH+AES256:!aNULL:!MD5:!DSS:!DH:!AES128', 'default' => 'ECDH+AESGCM:ECDH+AES256:!aNULL:!MD5:!DSS:!DH:!AES128',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
), ),
'system_tlsv13_cipher_list' => array(
'label' => $lng['serversettings']['ssl']['tlsv13_cipher_list'],
'settinggroup' => 'system',
'varname' => 'tlsv13_cipher_list',
'type' => 'string',
'string_emptyallowed' => true,
'default' => '',
'visible' => \Froxlor\Settings::Get('system.webserver') == "apache2" && \Froxlor\Settings::Get('system.apache24') == 1,
'save_method' => 'storeSettingField'
),
'system_ssl_cert_file' => array( 'system_ssl_cert_file' => array(
'label' => $lng['serversettings']['ssl']['ssl_cert_file'], 'label' => $lng['serversettings']['ssl']['ssl_cert_file'],
'settinggroup' => 'system', 'settinggroup' => 'system',
@@ -112,18 +102,9 @@ return array(
'string_type' => 'string', 'string_type' => 'string',
'string_emptyallowed' => false, 'string_emptyallowed' => false,
'default' => 'shmcb:/var/run/apache2/ocsp-stapling.cache(131072)', 'default' => 'shmcb:/var/run/apache2/ocsp-stapling.cache(131072)',
'visible' => \Froxlor\Settings::Get('system.webserver') == "apache2" && \Froxlor\Settings::Get('system.apache24') == 1, 'visible' => Settings::Get('system.webserver') == "apache2" && Settings::Get('system.apache24') == 1,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
), ),
'system_sessionticketsenabled' => array(
'label' => $lng['admin']['domain_sessionticketsenabled'],
'settinggroup' => 'system',
'varname' => 'sessionticketsenabled',
'type' => 'bool',
'default' => true,
'save_method' => 'storeSettingField',
'visible' => \Froxlor\Settings::Get('system.use_ssl') && (\Froxlor\Settings::Get('system.webserver') == "nginx" || (\Froxlor\Settings::Get('system.webserver') == "apache2" && \Froxlor\Settings::Get('system.apache24') == 1))
),
'system_leenabled' => array( 'system_leenabled' => array(
'label' => $lng['serversettings']['leenabled'], 'label' => $lng['serversettings']['leenabled'],
'settinggroup' => 'system', 'settinggroup' => 'system',
@@ -133,15 +114,6 @@ return array(
'cronmodule' => 'froxlor/letsencrypt', 'cronmodule' => 'froxlor/letsencrypt',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
), ),
'system_acmeshpath' => array(
'label' => $lng['serversettings']['acmeshpath'],
'settinggroup' => 'system',
'varname' => 'acmeshpath',
'type' => 'string',
'string_type' => 'file',
'default' => '/root/.acme.sh/acme.sh',
'save_method' => 'storeSettingField'
),
'system_letsencryptacmeconf' => array( 'system_letsencryptacmeconf' => array(
'label' => $lng['serversettings']['letsencryptacmeconf'], 'label' => $lng['serversettings']['letsencryptacmeconf'],
'settinggroup' => 'system', 'settinggroup' => 'system',
@@ -151,74 +123,66 @@ return array(
'default' => '/etc/apache2/conf-enabled/acme.conf', 'default' => '/etc/apache2/conf-enabled/acme.conf',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
), ),
/**
* currently the only option anyway
*
'system_leapiversion' => array( 'system_leapiversion' => array(
'label' => $lng['serversettings']['leapiversion'], 'label' => $lng['serversettings']['leapiversion'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'leapiversion', 'varname' => 'leapiversion',
'type' => 'option', 'type' => 'option',
'default' => '2', 'default' => '1',
'option_mode' => 'one', 'option_mode' => 'one',
'option_options' => array( 'option_options' => array(
'1' => 'ACME v1',
'2' => 'ACME v2' '2' => 'ACME v2'
), ),
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
), ),
*/
'system_letsencryptca' => array( 'system_letsencryptca' => array(
'label' => $lng['serversettings']['letsencryptca'], 'label' => $lng['serversettings']['letsencryptca'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'letsencryptca', 'varname' => 'letsencryptca',
'type' => 'option', 'type' => 'option',
'default' => 'letsencrypt', 'default' => 'testing',
'option_mode' => 'one', 'option_mode' => 'one',
'option_options' => array( 'option_options' => array(
'letsencrypt_test' => 'Let\'s Encrypt (Test / Staging)', 'testing' => 'https://acme-staging' . (Settings::Get('system.leapiversion') == '2' ? '-v02' : '') . '.api.letsencrypt.org (Test)',
'letsencrypt' => 'Let\'s Encrypt (Live)', 'production' => 'https://acme-v0' . Settings::Get('system.leapiversion') . '.api.letsencrypt.org (Live)'
'buypass_test' => 'Buypass (Test / Staging)',
'buypass' => 'Buypass (Live)',
'zerossl' => 'ZeroSSL (Live)'
), ),
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
), ),
'system_letsencryptcountrycode' => array(
'label' => $lng['serversettings']['letsencryptcountrycode'],
'settinggroup' => 'system',
'varname' => 'letsencryptcountrycode',
'type' => 'string',
'string_emptyallowed' => false,
'default' => 'DE',
'save_method' => 'storeSettingField'
),
'system_letsencryptstate' => array(
'label' => $lng['serversettings']['letsencryptstate'],
'settinggroup' => 'system',
'varname' => 'letsencryptstate',
'type' => 'string',
'string_emptyallowed' => false,
'default' => 'Hessen',
'save_method' => 'storeSettingField'
),
'system_letsencryptchallengepath' => array( 'system_letsencryptchallengepath' => array(
'label' => $lng['serversettings']['letsencryptchallengepath'], 'label' => $lng['serversettings']['letsencryptchallengepath'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'letsencryptchallengepath', 'varname' => 'letsencryptchallengepath',
'type' => 'string', 'type' => 'string',
'string_emptyallowed' => false, 'string_emptyallowed' => false,
'default' => \Froxlor\Froxlor::getInstallDir(), 'default' => FROXLOR_INSTALL_DIR,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
), ),
'system_letsencryptkeysize' => array( 'system_letsencryptkeysize' => array(
'label' => $lng['serversettings']['letsencryptkeysize'], 'label' => $lng['serversettings']['letsencryptkeysize'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'letsencryptkeysize', 'varname' => 'letsencryptkeysize',
'type' => 'option', 'type' => 'int',
'default' => '2048', 'int_min' => 2048,
'option_mode' => 'one', 'default' => 4096,
'option_options' => array(
'2048' => '2048',
'3072' => '3072',
'4096' => '4096',
'8192' => '8192'
),
'save_method' => 'storeSettingField'
),
'system_leecc' => array(
'label' => $lng['serversettings']['letsencryptecc'],
'settinggroup' => 'system',
'varname' => 'leecc',
'type' => 'option',
'default' => '0',
'option_mode' => 'one',
'option_options' => array(
'0' => '-',
'256' => 'ec-256',
'384' => 'ec-384'
),
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
), ),
'system_letsencryptreuseold' => array( 'system_letsencryptreuseold' => array(
@@ -226,15 +190,15 @@ return array(
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'letsencryptreuseold', 'varname' => 'letsencryptreuseold',
'type' => 'bool', 'type' => 'bool',
'default' => true, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
), ),
'system_le_domain_dnscheck' => array( 'system_disable_le_selfcheck' => array(
'label' => $lng['serversettings']['le_domain_dnscheck'], 'label' => $lng['serversettings']['disable_le_selfcheck'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'le_domain_dnscheck', 'varname' => 'disable_le_selfcheck',
'type' => 'bool', 'type' => 'bool',
'default' => true, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
) )
) )

View File

@@ -14,14 +14,12 @@
* @package Settings * @package Settings
* *
*/ */
return array( return array(
'groups' => array( 'groups' => array(
'fcgid' => array( 'fcgid' => array(
'title' => $lng['admin']['fcgid_settings'], 'title' => $lng['admin']['fcgid_settings'],
'websrv_avail' => array( 'websrv_avail' => array('apache2', 'lighttpd'),
'apache2',
'lighttpd'
),
'fields' => array( 'fields' => array(
'system_mod_fcgid_enabled' => array( 'system_mod_fcgid_enabled' => array(
'label' => $lng['serversettings']['mod_fcgid'], 'label' => $lng['serversettings']['mod_fcgid'],
@@ -30,10 +28,7 @@ return array(
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'plausibility_check_method' => array( 'plausibility_check_method' => 'checkFcgidPhpFpm',
'\\Froxlor\\Validate\\Check',
'checkFcgidPhpFpm'
),
'overview_option' => true 'overview_option' => true
), ),
'system_mod_fcgid_configdir' => array( 'system_mod_fcgid_configdir' => array(
@@ -43,11 +38,8 @@ return array(
'type' => 'string', 'type' => 'string',
'string_type' => 'confdir', 'string_type' => 'confdir',
'default' => '/var/www/php-fcgi-scripts/', 'default' => '/var/www/php-fcgi-scripts/',
'plausibility_check_method' => array( 'plausibility_check_method' => 'checkPathConflicts',
'\\Froxlor\\Validate\\Check', 'save_method' => 'storeSettingField',
'checkPathConflicts'
),
'save_method' => 'storeSettingField'
), ),
'system_mod_fcgid_tmpdir' => array( 'system_mod_fcgid_tmpdir' => array(
'label' => $lng['serversettings']['mod_fcgid']['tmpdir'], 'label' => $lng['serversettings']['mod_fcgid']['tmpdir'],
@@ -56,7 +48,7 @@ return array(
'type' => 'string', 'type' => 'string',
'string_type' => 'dir', 'string_type' => 'dir',
'default' => '/var/customers/tmp/', 'default' => '/var/customers/tmp/',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_mod_fcgid_peardir' => array( 'system_mod_fcgid_peardir' => array(
'label' => $lng['serversettings']['mod_fcgid']['peardir'], 'label' => $lng['serversettings']['mod_fcgid']['peardir'],
@@ -67,22 +59,17 @@ return array(
'string_delimiter' => ':', 'string_delimiter' => ':',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '/usr/share/php/:/usr/share/php5/', 'default' => '/usr/share/php/:/usr/share/php5/',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_mod_fcgid_wrapper' => array( 'system_mod_fcgid_wrapper' => array(
'label' => $lng['serversettings']['mod_fcgid']['wrapper'], 'label' => $lng['serversettings']['mod_fcgid']['wrapper'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mod_fcgid_wrapper', 'varname' => 'mod_fcgid_wrapper',
'type' => 'option', 'type' => 'option',
'option_options' => array( 'option_options' => array(0 => 'ScriptAlias', 1=> 'FcgidWrapper'),
0 => 'ScriptAlias',
1 => 'FcgidWrapper'
),
'default' => 1, 'default' => 1,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => array( 'websrv_avail' => array('apache2')
'apache2'
)
), ),
'system_mod_fcgid_starter' => array( 'system_mod_fcgid_starter' => array(
'label' => $lng['serversettings']['mod_fcgid']['starter'], 'label' => $lng['serversettings']['mod_fcgid']['starter'],
@@ -90,7 +77,7 @@ return array(
'varname' => 'mod_fcgid_starter', 'varname' => 'mod_fcgid_starter',
'type' => 'int', 'type' => 'int',
'default' => 0, 'default' => 0,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_mod_fcgid_maxrequests' => array( 'system_mod_fcgid_maxrequests' => array(
'label' => $lng['serversettings']['mod_fcgid']['maxrequests'], 'label' => $lng['serversettings']['mod_fcgid']['maxrequests'],
@@ -98,7 +85,7 @@ return array(
'varname' => 'mod_fcgid_maxrequests', 'varname' => 'mod_fcgid_maxrequests',
'type' => 'int', 'type' => 'int',
'default' => 250, 'default' => 250,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_mod_fcgid_defaultini' => array( 'system_mod_fcgid_defaultini' => array(
'label' => $lng['serversettings']['mod_fcgid']['defaultini'], 'label' => $lng['serversettings']['mod_fcgid']['defaultini'],
@@ -107,10 +94,8 @@ return array(
'type' => 'option', 'type' => 'option',
'default' => '1', 'default' => '1',
'option_mode' => 'one', 'option_mode' => 'one',
'option_options_method' => array( 'option_options_method' => 'getPhpConfigs',
'\\Froxlor\\Http\\PhpConfig', 'save_method' => 'storeSettingField',
'getPhpConfigs'),
'save_method' => 'storeSettingField'
), ),
'system_mod_fcgid_idle_timeout' => array( 'system_mod_fcgid_idle_timeout' => array(
'label' => $lng['serversettings']['mod_fcgid']['idle_timeout'], 'label' => $lng['serversettings']['mod_fcgid']['idle_timeout'],

View File

@@ -11,9 +11,10 @@
* @copyright (c) the authors * @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2010-) * @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package \Froxlor\Settings * @package Settings
* *
*/ */
return array( return array(
'groups' => array( 'groups' => array(
'phpfpm' => array( 'phpfpm' => array(
@@ -26,10 +27,7 @@ return array(
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'plausibility_check_method' => array( 'plausibility_check_method' => 'checkFcgidPhpFpm',
'\\Froxlor\\Validate\\Check',
'checkFcgidPhpFpm'
),
'overview_option' => true 'overview_option' => true
), ),
'system_phpfpm_defaultini' => array( 'system_phpfpm_defaultini' => array(
@@ -39,10 +37,7 @@ return array(
'type' => 'option', 'type' => 'option',
'default' => '1', 'default' => '1',
'option_mode' => 'one', 'option_mode' => 'one',
'option_options_method' => array( 'option_options_method' => 'getPhpConfigs',
'\\Froxlor\\Http\\PhpConfig',
'getPhpConfigs'
),
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
), ),
'system_phpfpm_aliasconfigdir' => array( 'system_phpfpm_aliasconfigdir' => array(
@@ -99,8 +94,8 @@ return array(
'settinggroup' => 'phpfpm', 'settinggroup' => 'phpfpm',
'varname' => 'use_mod_proxy', 'varname' => 'use_mod_proxy',
'type' => 'bool', 'type' => 'bool',
'default' => true, 'default' => false,
'visible' => \Froxlor\Settings::Get('system.apache24'), 'visible' => Settings::Get('system.apache24'),
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
), ),
'system_phpfpm_ini_flags' => array( 'system_phpfpm_ini_flags' => array(
@@ -135,7 +130,7 @@ return array(
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
) )
) ),
) ),
) ),
); );

View File

@@ -14,6 +14,7 @@
* @package Settings * @package Settings
* *
*/ */
return array( return array(
'groups' => array( 'groups' => array(
'perl' => array( 'perl' => array(
@@ -26,9 +27,7 @@ return array(
'type' => 'string', 'type' => 'string',
'default' => '/usr/bin/perl', 'default' => '/usr/bin/perl',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => array( 'websrv_avail' => array('lighttpd')
'lighttpd'
)
), ),
'system_perl_suexecworkaround' => array( 'system_perl_suexecworkaround' => array(
'label' => $lng['serversettings']['perl']['suexecworkaround'], 'label' => $lng['serversettings']['perl']['suexecworkaround'],
@@ -37,9 +36,7 @@ return array(
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => array( 'websrv_avail' => array('apache2')
'apache2'
)
), ),
'system_perl_suexeccgipath' => array( 'system_perl_suexeccgipath' => array(
'label' => $lng['serversettings']['perl']['suexeccgipath'], 'label' => $lng['serversettings']['perl']['suexeccgipath'],
@@ -49,9 +46,7 @@ return array(
'string_type' => 'dir', 'string_type' => 'dir',
'default' => '/var/www/cgi-bin/', 'default' => '/var/www/cgi-bin/',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => array( 'websrv_avail' => array('apache2')
'apache2'
)
), ),
'perl_server' => array( 'perl_server' => array(
'label' => $lng['serversettings']['perl_server'], 'label' => $lng['serversettings']['perl_server'],
@@ -60,13 +55,11 @@ return array(
'type' => 'string', 'type' => 'string',
'default' => 'unix:/var/run/nginx/cgiwrap-dispatch.sock', 'default' => 'unix:/var/run/nginx/cgiwrap-dispatch.sock',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'websrv_avail' => array( 'websrv_avail' => array('nginx')
'nginx' ),
) ),
) ),
) ),
)
)
); );
?> ?>

View File

@@ -16,6 +16,7 @@
* @package Settings * @package Settings
* *
*/ */
return array( return array(
'groups' => array( 'groups' => array(
'statistics' => array( 'statistics' => array(
@@ -28,13 +29,8 @@ return array(
'type' => 'option', 'type' => 'option',
'default' => 2, 'default' => 2,
'option_mode' => 'one', 'option_mode' => 'one',
'option_options' => array( 'option_options' => array(0 => $lng['admin']['webalizer']['normal'], 1 => $lng['admin']['webalizer']['quiet'], 2 => $lng['admin']['webalizer']['veryquiet']),
0 => $lng['admin']['webalizer']['normal'],
1 => $lng['admin']['webalizer']['quiet'],
2 => $lng['admin']['webalizer']['veryquiet']
),
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => \Froxlor\Settings::Get('system.awstats_enabled') == 0
), ),
'system_awstats_enabled' => array( 'system_awstats_enabled' => array(
'label' => $lng['serversettings']['awstats_enabled'], 'label' => $lng['serversettings']['awstats_enabled'],
@@ -42,7 +38,7 @@ return array(
'varname' => 'awstats_enabled', 'varname' => 'awstats_enabled',
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_awstats_path' => array( 'system_awstats_path' => array(
'label' => $lng['serversettings']['awstats_path'], 'label' => $lng['serversettings']['awstats_path'],
@@ -52,7 +48,6 @@ return array(
'string_type' => 'dir', 'string_type' => 'dir',
'default' => '/usr/bin/', 'default' => '/usr/bin/',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => \Froxlor\Settings::Get('system.awstats_enabled') == 1
), ),
'system_awstats_awstatspath' => array( 'system_awstats_awstatspath' => array(
'label' => $lng['serversettings']['awstats_awstatspath'], 'label' => $lng['serversettings']['awstats_awstatspath'],
@@ -62,7 +57,6 @@ return array(
'string_type' => 'dir', 'string_type' => 'dir',
'default' => '/usr/bin/', 'default' => '/usr/bin/',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => \Froxlor\Settings::Get('system.awstats_enabled') == 1
), ),
'system_awstats_conf' => array( 'system_awstats_conf' => array(
'label' => $lng['serversettings']['awstats_conf'], 'label' => $lng['serversettings']['awstats_conf'],
@@ -72,7 +66,6 @@ return array(
'string_type' => 'dir', 'string_type' => 'dir',
'default' => '/etc/awstats/', 'default' => '/etc/awstats/',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => \Froxlor\Settings::Get('system.awstats_enabled') == 1
), ),
'system_awstats_icons' => array( 'system_awstats_icons' => array(
'label' => $lng['serversettings']['awstats_icons'], 'label' => $lng['serversettings']['awstats_icons'],
@@ -82,16 +75,6 @@ return array(
'string_type' => 'dir', 'string_type' => 'dir',
'default' => '/usr/share/awstats/icon/', 'default' => '/usr/share/awstats/icon/',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'visible' => \Froxlor\Settings::Get('system.awstats_enabled') == 1
),
'system_awstats_logformat' => array(
'label' => $lng['serversettings']['awstats']['logformat'],
'settinggroup' => 'system',
'varname' => 'awstats_logformat',
'type' => 'string',
'default' => '1',
'save_method' => 'storeSettingField',
'visible' => \Froxlor\Settings::Get('system.awstats_enabled') == 1
) )
) )
) )

View File

@@ -16,6 +16,7 @@
* @package Settings * @package Settings
* *
*/ */
return array( return array(
'groups' => array( 'groups' => array(
'mail' => array( 'mail' => array(
@@ -29,7 +30,7 @@ return array(
'default' => 2000, 'default' => 2000,
'int_min' => 1, 'int_min' => 1,
'int_max' => 65535, 'int_max' => 65535,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_vmail_gid' => array( 'system_vmail_gid' => array(
'label' => $lng['serversettings']['vmail_gid'], 'label' => $lng['serversettings']['vmail_gid'],
@@ -39,7 +40,7 @@ return array(
'default' => 2000, 'default' => 2000,
'int_min' => 1, 'int_min' => 1,
'int_max' => 65535, 'int_max' => 65535,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_vmail_homedir' => array( 'system_vmail_homedir' => array(
'label' => $lng['serversettings']['vmail_homedir'], 'label' => $lng['serversettings']['vmail_homedir'],
@@ -48,7 +49,7 @@ return array(
'type' => 'string', 'type' => 'string',
'string_type' => 'dir', 'string_type' => 'dir',
'default' => '/var/customers/mail/', 'default' => '/var/customers/mail/',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_vmail_maildirname' => array( 'system_vmail_maildirname' => array(
'label' => $lng['serversettings']['vmail_maildirname'], 'label' => $lng['serversettings']['vmail_maildirname'],
@@ -58,7 +59,7 @@ return array(
'string_type' => 'dir', 'string_type' => 'dir',
'default' => 'Maildir', 'default' => 'Maildir',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'panel_sendalternativemail' => array( 'panel_sendalternativemail' => array(
'label' => $lng['serversettings']['sendalternativemail'], 'label' => $lng['serversettings']['sendalternativemail'],
@@ -66,7 +67,7 @@ return array(
'varname' => 'sendalternativemail', 'varname' => 'sendalternativemail',
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_mail_quota_enabled' => array( 'system_mail_quota_enabled' => array(
'label' => $lng['serversettings']['mail_quota_enabled'], 'label' => $lng['serversettings']['mail_quota_enabled'],
@@ -74,7 +75,7 @@ return array(
'varname' => 'mail_quota_enabled', 'varname' => 'mail_quota_enabled',
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_mail_quota' => array( 'system_mail_quota' => array(
'label' => $lng['serversettings']['mail_quota'], 'label' => $lng['serversettings']['mail_quota'],
@@ -82,7 +83,7 @@ return array(
'varname' => 'mail_quota', 'varname' => 'mail_quota',
'type' => 'int', 'type' => 'int',
'default' => 100, 'default' => 100,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_catchall_enabled' => array( 'system_catchall_enabled' => array(
'label' => $lng['serversettings']['catchall_enabled'], 'label' => $lng['serversettings']['catchall_enabled'],
@@ -92,29 +93,13 @@ return array(
'default' => true, 'default' => true,
'save_method' => 'storeSettingResetCatchall', 'save_method' => 'storeSettingResetCatchall',
), ),
'mail_greylist_enabled' => array(
'label' => $lng['serversettings']['greylist_enabled'],
'settinggroup' => 'mail',
'varname' => 'greylist_enabled',
'type' => 'bool',
'default' => true,
'save_method' => 'storeSettingField',
),
'mail_greylist_disabled_default' => array(
'label' => $lng['serversettings']['greylist_disabled_default'],
'settinggroup' => 'mail',
'varname' => 'greylist_disabled_default',
'type' => 'bool',
'default' => false,
'save_method' => 'storeSettingField',
),
'system_mailtraffic_enabled' => array( 'system_mailtraffic_enabled' => array(
'label' => $lng['serversettings']['mailtraffic_enabled'], 'label' => $lng['serversettings']['mailtraffic_enabled'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'mailtraffic_enabled', 'varname' => 'mailtraffic_enabled',
'type' => 'bool', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_mdaserver' => array( 'system_mdaserver' => array(
'label' => $lng['serversettings']['mdaserver'], 'label' => $lng['serversettings']['mdaserver'],
@@ -123,11 +108,8 @@ return array(
'type' => 'option', 'type' => 'option',
'option_mode' => 'one', 'option_mode' => 'one',
'default' => 'dovecot', 'default' => 'dovecot',
'option_options' => array( 'option_options' => array('courier' => 'Courier', 'dovecot' => 'Dovecot'),
'courier' => 'Courier', 'save_method' => 'storeSettingField',
'dovecot' => 'Dovecot'
),
'save_method' => 'storeSettingField'
), ),
'system_mdalog' => array( 'system_mdalog' => array(
'label' => $lng['serversettings']['mdalog'], 'label' => $lng['serversettings']['mdalog'],
@@ -137,7 +119,7 @@ return array(
'string_type' => 'file', 'string_type' => 'file',
'default' => '/var/log/mail.log', 'default' => '/var/log/mail.log',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_mtaserver' => array( 'system_mtaserver' => array(
'label' => $lng['serversettings']['mtaserver'], 'label' => $lng['serversettings']['mtaserver'],
@@ -146,11 +128,8 @@ return array(
'type' => 'option', 'type' => 'option',
'option_mode' => 'one', 'option_mode' => 'one',
'default' => 'postfix', 'default' => 'postfix',
'option_options' => array( 'option_options' => array('exim4' => 'Exim4', 'postfix' => 'Postfix'),
'exim4' => 'Exim4', 'save_method' => 'storeSettingField',
'postfix' => 'Postfix'
),
'save_method' => 'storeSettingField'
), ),
'system_mtalog' => array( 'system_mtalog' => array(
'label' => $lng['serversettings']['mtalog'], 'label' => $lng['serversettings']['mtalog'],
@@ -160,11 +139,11 @@ return array(
'string_type' => 'file', 'string_type' => 'file',
'default' => '/var/log/mail.log', 'default' => '/var/log/mail.log',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
) ),
) ),
) ),
) ),
); );
?> ?>

View File

@@ -16,6 +16,7 @@
* @package Settings * @package Settings
* *
*/ */
return array( return array(
'groups' => array( 'groups' => array(
'ftpserver' => array( 'ftpserver' => array(
@@ -28,14 +29,11 @@ return array(
'type' => 'option', 'type' => 'option',
'default' => 'proftpd', 'default' => 'proftpd',
'option_mode' => 'one', 'option_mode' => 'one',
'option_options' => array( 'option_options' => array('proftpd' => 'Proftpd', 'pureftpd' => 'Pureftpd'),
'proftpd' => 'Proftpd', 'save_method' => 'storeSettingField',
'pureftpd' => 'Pureftpd' ),
),
), ),
'save_method' => 'storeSettingField'
)
)
)
) )
); );

View File

@@ -16,6 +16,7 @@
* @package Settings * @package Settings
* *
*/ */
return array( return array(
'groups' => array( 'groups' => array(
'nameserver' => array( 'nameserver' => array(
@@ -43,12 +44,9 @@ return array(
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'dns_server', 'varname' => 'dns_server',
'type' => 'option', 'type' => 'option',
'default' => 'Bind', 'default' => 'bind',
'option_mode' => 'one', 'option_mode' => 'one',
'option_options' => array( 'option_options' => array('bind' => 'Bind9', 'pdns' => 'PowerDNS'),
'Bind' => 'Bind9',
'PowerDNS' => 'PowerDNS'
),
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
), ),
'system_bindconf_directory' => array( 'system_bindconf_directory' => array(
@@ -58,7 +56,7 @@ return array(
'type' => 'string', 'type' => 'string',
'string_type' => 'dir', 'string_type' => 'dir',
'default' => '/etc/bind/', 'default' => '/etc/bind/',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_bindreload_command' => array( 'system_bindreload_command' => array(
'label' => $lng['serversettings']['bindreload_command'], 'label' => $lng['serversettings']['bindreload_command'],
@@ -66,7 +64,7 @@ return array(
'varname' => 'bindreload_command', 'varname' => 'bindreload_command',
'type' => 'string', 'type' => 'string',
'default' => '/etc/init.d/bind9 reload', 'default' => '/etc/init.d/bind9 reload',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_nameservers' => array( 'system_nameservers' => array(
'label' => $lng['serversettings']['nameservers'], 'label' => $lng['serversettings']['nameservers'],
@@ -76,7 +74,7 @@ return array(
'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' => array( 'system_mxservers' => array(
'label' => $lng['serversettings']['mxservers'], 'label' => $lng['serversettings']['mxservers'],
@@ -86,7 +84,7 @@ return array(
'string_regexp' => '/^(([0-9]+ [a-z0-9\-\._]+, ?)*[0-9]+ [a-z0-9\-\._]+)?$/i', 'string_regexp' => '/^(([0-9]+ [a-z0-9\-\._]+, ?)*[0-9]+ [a-z0-9\-\._]+)?$/i',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_axfrservers' => array( 'system_axfrservers' => array(
'label' => $lng['serversettings']['axfrservers'], 'label' => $lng['serversettings']['axfrservers'],
@@ -97,20 +95,7 @@ return array(
'string_delimiter' => ',', 'string_delimiter' => ',',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
),
'system_powerdns_mode' => array(
'label' => $lng['serversettings']['powerdns_mode'],
'settinggroup' => 'system',
'varname' => 'powerdns_mode',
'type' => 'option',
'default' => 'Native',
'option_mode' => 'one',
'option_options' => array(
'Native' => 'Native',
'Master' => 'Master'
),
'save_method' => 'storeSettingField'
), ),
'system_dns_createmailentry' => array( 'system_dns_createmailentry' => array(
'label' => $lng['serversettings']['mail_also_with_mxservers'], 'label' => $lng['serversettings']['mail_also_with_mxservers'],
@@ -120,22 +105,6 @@ return array(
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
), ),
'system_dns_createcaaentry' => array(
'label' => $lng['serversettings']['caa_entry'],
'settinggroup' => 'system',
'varname' => 'dns_createcaaentry',
'type' => 'bool',
'default' => true,
'save_method' => 'storeSettingField'
),
'caa_caa_entry' => array(
'label' => $lng['serversettings']['caa_entry_custom'],
'settinggroup' => 'caa',
'varname' => 'caa_entry',
'type' => 'text',
'default' => '',
'save_method' => 'storeSettingField'
),
'system_defaultttl' => array( 'system_defaultttl' => array(
'label' => $lng['serversettings']['defaultttl'], 'label' => $lng['serversettings']['defaultttl'],
'settinggroup' => 'system', 'settinggroup' => 'system',
@@ -144,19 +113,9 @@ return array(
'default' => 604800, /* 1 week */ 'default' => 604800, /* 1 week */
'int_min' => 3600, /* 1 hour */ 'int_min' => 3600, /* 1 hour */
'int_max' => 2147483647, /* integer max */ 'int_max' => 2147483647, /* integer max */
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
),
),
),
), ),
'system_soaemail' => array(
'label' => $lng['serversettings']['soaemail'],
'settinggroup' => 'system',
'varname' => 'soaemail',
'type' => 'string',
'string_type' => 'mail',
'string_emptyallowed' => true,
'default' => '',
'save_method' => 'storeSettingField'
)
)
)
)
); );

View File

@@ -16,6 +16,7 @@
* @package Settings * @package Settings
* *
*/ */
return array( return array(
'groups' => array( 'groups' => array(
'logging' => array( 'logging' => array(
@@ -37,11 +38,8 @@ return array(
'type' => 'option', 'type' => 'option',
'default' => 1, 'default' => 1,
'option_mode' => 'one', 'option_mode' => 'one',
'option_options' => array( 'option_options' => array(1 => $lng['admin']['logger']['normal'], 2 => $lng['admin']['logger']['paranoid']),
1 => $lng['admin']['logger']['normal'], 'save_method' => 'storeSettingField',
2 => $lng['admin']['logger']['paranoid']
),
'save_method' => 'storeSettingField'
), ),
'logger_logtypes' => array( 'logger_logtypes' => array(
'label' => $lng['serversettings']['logger']['types'], 'label' => $lng['serversettings']['logger']['types'],
@@ -50,12 +48,8 @@ return array(
'type' => 'option', 'type' => 'option',
'default' => 'syslog,mysql', 'default' => 'syslog,mysql',
'option_mode' => 'multiple', 'option_mode' => 'multiple',
'option_options' => array( 'option_options' => array('syslog' => 'syslog', 'file' => 'file', 'mysql' => 'mysql'),
'syslog' => 'syslog', 'save_method' => 'storeSettingField',
'file' => 'file',
'mysql' => 'mysql'
),
'save_method' => 'storeSettingField'
), ),
'logger_logfile' => array( 'logger_logfile' => array(
'label' => $lng['serversettings']['logger']['logfile'], 'label' => $lng['serversettings']['logger']['logfile'],
@@ -65,7 +59,7 @@ return array(
'string_type' => 'file', 'string_type' => 'file',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'logger_log_cron' => array( 'logger_log_cron' => array(
'label' => $lng['serversettings']['logger']['logcron'], 'label' => $lng['serversettings']['logger']['logcron'],
@@ -79,10 +73,10 @@ return array(
1 => $lng['serversettings']['logger']['logcronoption']['once'], 1 => $lng['serversettings']['logger']['logcronoption']['once'],
2 => $lng['serversettings']['logger']['logcronoption']['always'] 2 => $lng['serversettings']['logger']['logcronoption']['always']
), ),
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
) ),
) ),
) ),
) )
); );

View File

@@ -13,9 +13,10 @@
* @author Florian Lippert <flo@syscp.org> (2003-2009) * @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-) * @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package \Froxlor\Settings * @package Settings
* *
*/ */
return array( return array(
'groups' => array( 'groups' => array(
'dkim' => array( 'dkim' => array(
@@ -37,16 +38,7 @@ return array(
'type' => 'string', 'type' => 'string',
'string_type' => 'dir', 'string_type' => 'dir',
'default' => '/etc/postfix/dkim/', 'default' => '/etc/postfix/dkim/',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
),
'dkim_privkeysuffix' => array(
'label' => $lng['dkim']['privkeysuffix'],
'settinggroup' => 'dkim',
'varname' => 'privkeysuffix',
'type' => 'string',
'string_regexp' => '/^[a-z0-9\._]+$/i',
'default' => '.priv',
'save_method' => 'storeSettingField'
), ),
'dkim_domains' => array( 'dkim_domains' => array(
'label' => $lng['dkim']['dkim_domains'], 'label' => $lng['dkim']['dkim_domains'],
@@ -55,7 +47,7 @@ return array(
'type' => 'string', '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' => array( 'dkim_dkimkeys' => array(
'label' => $lng['dkim']['dkim_dkimkeys'], 'label' => $lng['dkim']['dkim_dkimkeys'],
@@ -64,7 +56,7 @@ return array(
'type' => 'string', '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' => array( 'dkim_algorithm' => array(
'label' => $lng['dkim']['dkim_algorithm'], 'label' => $lng['dkim']['dkim_algorithm'],
@@ -73,12 +65,8 @@ return array(
'type' => 'option', 'type' => 'option',
'default' => 'all', 'default' => 'all',
'option_mode' => 'multiple', 'option_mode' => 'multiple',
'option_options' => array( 'option_options' => array('all' => 'All', 'sha1' => 'SHA1', 'sha256' => 'SHA256'),
'all' => 'All', 'save_method' => 'storeSettingFieldInsertBindTask',
'sha1' => 'SHA1',
'sha256' => 'SHA256'
),
'save_method' => 'storeSettingFieldInsertBindTask'
), ),
'dkim_servicetype' => array( 'dkim_servicetype' => array(
'label' => $lng['dkim']['dkim_servicetype'], 'label' => $lng['dkim']['dkim_servicetype'],
@@ -87,27 +75,21 @@ return array(
'type' => 'option', 'type' => 'option',
'default' => '0', 'default' => '0',
'option_mode' => 'one', 'option_mode' => 'one',
'option_options' => array( 'option_options' => array('0' => 'All', '1' => 'E-Mail'),
'0' => 'All', 'save_method' => 'storeSettingFieldInsertBindTask',
'1' => 'E-Mail'
),
'save_method' => 'storeSettingFieldInsertBindTask'
), ),
'dkim_keylength' => array( 'dkim_keylength' => array(
'label' => array( 'label' => array(
'title' => $lng['dkim']['dkim_keylength']['title'], 'title' => $lng['dkim']['dkim_keylength']['title'],
'description' => sprintf($lng['dkim']['dkim_keylength']['description'], \Froxlor\Settings::Get('dkim.dkim_prefix')) 'description' => sprintf($lng['dkim']['dkim_keylength']['description'], Settings::Get('dkim.dkim_prefix'))
), ),
'settinggroup' => 'dkim', 'settinggroup' => 'dkim',
'varname' => 'dkim_keylength', 'varname' => 'dkim_keylength',
'type' => 'option', 'type' => 'option',
'default' => '1024', 'default' => '1024',
'option_mode' => 'one', 'option_mode' => 'one',
'option_options' => array( 'option_options' => array('1024' => '1024 Bit', '2048' => '2048 Bit'),
'1024' => '1024 Bit', 'save_method' => 'storeSettingFieldInsertBindTask',
'2048' => '2048 Bit'
),
'save_method' => 'storeSettingFieldInsertBindTask'
), ),
'dkim_notes' => array( 'dkim_notes' => array(
'label' => $lng['dkim']['dkim_notes'], 'label' => $lng['dkim']['dkim_notes'],
@@ -116,7 +98,25 @@ return array(
'type' => 'string', 'type' => 'string',
'string_regexp' => '/^[a-z0-9\._]+$/i', 'string_regexp' => '/^[a-z0-9\._]+$/i',
'default' => '', 'default' => '',
'save_method' => 'storeSettingFieldInsertBindTask' 'save_method' => 'storeSettingFieldInsertBindTask',
),
'dkim_add_adsp' => array(
'label' => $lng['dkim']['dkim_add_adsp'],
'settinggroup' => 'dkim',
'varname' => 'dkim_add_adsp',
'type' => 'bool',
'default' => true,
'save_method' => 'storeSettingFieldInsertBindTask',
),
'dkim_add_adsppolicy' => array(
'label' => $lng['dkim']['dkim_add_adsppolicy'],
'settinggroup' => 'dkim',
'varname' => 'dkim_add_adsppolicy',
'type' => 'option',
'default' => '1',
'option_mode' => 'one',
'option_options' => array('0' => 'Unknown', '1' => 'All', '2' => 'Discardable'),
'save_method' => 'storeSettingFieldInsertBindTask',
), ),
'dkimrestart_command' => array( 'dkimrestart_command' => array(
'label' => $lng['dkim']['dkimrestart_command'], 'label' => $lng['dkim']['dkimrestart_command'],
@@ -124,11 +124,11 @@ return array(
'varname' => 'dkimrestart_command', 'varname' => 'dkimrestart_command',
'type' => 'string', 'type' => 'string',
'default' => '/etc/init.d/dkim-filter restart', 'default' => '/etc/init.d/dkim-filter restart',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
) ),
) ),
) ),
) ),
); );
?> ?>

View File

@@ -14,6 +14,7 @@
* @package Settings * @package Settings
* *
*/ */
return array( return array(
'groups' => array( 'groups' => array(
'spf' => array( 'spf' => array(

View File

@@ -0,0 +1,144 @@
<?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
*
*/
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',
'overview_option' => true
),
'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',
'plausibility_check_method' => 'setCycleOfCronjob',
),
'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' => '',
),
'ticket_default_priority' => array(
'label' => $lng['serversettings']['ticket']['default_priority'],
'settinggroup' => 'ticket',
'varname' => 'default_priority',
'type' => 'option',
'default' => 2,
'option_mode' => 'one',
'option_options' => array(1 => $lng['ticket']['high'], 2 => $lng['ticket']['normal'], 3 => $lng['ticket']['low']),
'save_method' => 'storeSettingField',
),
),
),
)
);
?>

View File

@@ -16,6 +16,7 @@
* @package Settings * @package Settings
* *
*/ */
return array( return array(
'groups' => array( 'groups' => array(
'security' => array( 'security' => array(
@@ -27,7 +28,7 @@ return array(
'varname' => 'unix_names', 'varname' => 'unix_names',
'type' => 'bool', 'type' => 'bool',
'default' => true, 'default' => true,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_mailpwcleartext' => array( 'system_mailpwcleartext' => array(
'label' => $lng['serversettings']['mailpwcleartext'], 'label' => $lng['serversettings']['mailpwcleartext'],
@@ -35,7 +36,7 @@ return array(
'varname' => 'mailpwcleartext', 'varname' => 'mailpwcleartext',
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_passwordcryptfunc' => array( 'system_passwordcryptfunc' => array(
'label' => $lng['serversettings']['passwordcryptfunc'], 'label' => $lng['serversettings']['passwordcryptfunc'],
@@ -44,11 +45,8 @@ return array(
'type' => 'option', 'type' => 'option',
'default' => 0, 'default' => 0,
'option_mode' => 'one', 'option_mode' => 'one',
'option_options_method' => array( 'option_options_method' => 'getAvailablePasswordHashes',
'\\Froxlor\\System\\Crypt', 'save_method' => 'storeSettingField',
'getAvailablePasswordHashes'
),
'save_method' => 'storeSettingField'
), ),
'system_allow_error_report_admin' => array( 'system_allow_error_report_admin' => array(
'label' => $lng['serversettings']['allow_error_report_admin'], 'label' => $lng['serversettings']['allow_error_report_admin'],
@@ -56,7 +54,7 @@ return array(
'varname' => 'allow_error_report_admin', 'varname' => 'allow_error_report_admin',
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_allow_error_report_customer' => array( 'system_allow_error_report_customer' => array(
'label' => $lng['serversettings']['allow_error_report_customer'], 'label' => $lng['serversettings']['allow_error_report_customer'],
@@ -64,7 +62,7 @@ return array(
'varname' => 'allow_error_report_customer', 'varname' => 'allow_error_report_customer',
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_allow_customer_shell' => array( 'system_allow_customer_shell' => array(
'label' => $lng['serversettings']['allow_allow_customer_shell'], 'label' => $lng['serversettings']['allow_allow_customer_shell'],
@@ -72,7 +70,7 @@ return array(
'varname' => 'allow_customer_shell', 'varname' => 'allow_customer_shell',
'type' => 'bool', 'type' => 'bool',
'default' => false, 'default' => false,
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'system_available_shells' => array( 'system_available_shells' => array(
'label' => $lng['serversettings']['available_shells'], 'label' => $lng['serversettings']['available_shells'],
@@ -81,21 +79,8 @@ return array(
'type' => 'string', 'type' => 'string',
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField'
),
'system_froxlorusergroup' => array(
'label' => $lng['serversettings']['froxlorusergroup'],
'settinggroup' => 'system',
'varname' => 'froxlorusergroup',
'type' => 'string',
'default' => '',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'plausibility_check_method' => array( )
'\\Froxlor\\Validate\\Check',
'checkLocalGroup'
),
'visible' => \Froxlor\Settings::Get('system.nssextrausers')
),
) )
) )
) )

View File

@@ -13,6 +13,7 @@
* @package Settings * @package Settings
* *
*/ */
return array( return array(
'groups' => array( 'groups' => array(
'diskquota' => array( 'diskquota' => array(
@@ -33,7 +34,7 @@ return array(
'varname' => 'diskquota_repquota_path', 'varname' => 'diskquota_repquota_path',
'type' => 'string', 'type' => 'string',
'default' => '/usr/sbin/repquota', 'default' => '/usr/sbin/repquota',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'diskquota_quotatool_path' => array( 'diskquota_quotatool_path' => array(
'label' => $lng['serversettings']['diskquota_quotatool_path']['description'], 'label' => $lng['serversettings']['diskquota_quotatool_path']['description'],
@@ -41,7 +42,7 @@ return array(
'varname' => 'diskquota_quotatool_path', 'varname' => 'diskquota_quotatool_path',
'type' => 'string', 'type' => 'string',
'default' => '/usr/bin/quotatool', 'default' => '/usr/bin/quotatool',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
), ),
'diskquota_customer_partition' => array( 'diskquota_customer_partition' => array(
'label' => $lng['serversettings']['diskquota_customer_partition']['description'], 'label' => $lng['serversettings']['diskquota_customer_partition']['description'],
@@ -49,11 +50,11 @@ return array(
'varname' => 'diskquota_customer_partition', 'varname' => 'diskquota_customer_partition',
'type' => 'string', 'type' => 'string',
'default' => '/dev/root', 'default' => '/dev/root',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
) ),
) ),
) ),
) ),
); );
?> ?>

View File

View File

@@ -16,24 +16,23 @@
* @package Panel * @package Panel
* *
*/ */
define('AREA', 'admin'); define('AREA', 'admin');
require './lib/init.php'; require './lib/init.php';
use Froxlor\Database\Database;
use Froxlor\Settings;
use Froxlor\Api\Commands\Admins as Admins;
if (isset($_POST['id'])) { if (isset($_POST['id'])) {
$id = intval($_POST['id']); $id = intval($_POST['id']);
} elseif(isset($_GET['id'])) { } elseif(isset($_GET['id'])) {
$id = intval($_GET['id']); $id = intval($_GET['id']);
} }
if ($page == 'admins' && $userinfo['change_serversettings'] == '1') { if ($page == 'admins'
&& $userinfo['change_serversettings'] == '1'
) {
if ($action == '') { if ($action == '') {
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_admins"); $log->logAction(ADM_ACTION, LOG_NOTICE, "viewed admin_admins");
$fields = array( $fields = array(
'loginname' => $lng['login']['username'], 'loginname' => $lng['login']['username'],
'name' => $lng['customer']['name'], 'name' => $lng['customer']['name'],
@@ -43,29 +42,23 @@ if ($page == 'admins' && $userinfo['change_serversettings'] == '1') {
'traffic_used' => $lng['customer']['traffic'] . ' (' . $lng['panel']['used'] . ')', 'traffic_used' => $lng['customer']['traffic'] . ' (' . $lng['panel']['used'] . ')',
'deactivated' => $lng['admin']['deactivated'] 'deactivated' => $lng['admin']['deactivated']
); );
try { $paging = new paging($userinfo, TABLE_PANEL_ADMINS, $fields);
// get total count
$json_result = Admins::getLocal($userinfo)->listingCount();
$result = json_decode($json_result, true)['data'];
// initialize pagination and filtering
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
// get list
$json_result = Admins::getLocal($userinfo, $paging->getApiCommandParams())->listing();
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$admins = ''; $admins = '';
$result_stmt = Database::query("SELECT * FROM `" . TABLE_PANEL_ADMINS . "` " . $paging->getSqlWhere(false) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
$numrows_admins = Database::num_rows();
$paging->setEntries($numrows_admins);
$sortcode = $paging->getHtmlSortCode($lng, true); $sortcode = $paging->getHtmlSortCode($lng, true);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s); $arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng); $searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s); $pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$i = 0;
$count = 0; $count = 0;
$dec_places = Settings::Get('panel.decimal_places'); $dec_places = Settings::Get('panel.decimal_places');
foreach ($result['list'] as $row) { while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
if ($paging->checkDisplay($i)) {
$row['traffic_used'] = round($row['traffic_used'] / (1024 * 1024), $dec_places); $row['traffic_used'] = round($row['traffic_used'] / (1024 * 1024), $dec_places);
$row['traffic'] = round($row['traffic'] / (1024 * 1024), $dec_places); $row['traffic'] = round($row['traffic'] / (1024 * 1024), $dec_places);
@@ -98,38 +91,37 @@ if ($page == 'admins' && $userinfo['change_serversettings'] == '1') {
$traffic_percent = 100; $traffic_percent = 100;
} }
$row = \Froxlor\PhpHelper::strReplaceArray('-1', 'UL', $row, 'customers domains diskspace traffic mysqls emails email_accounts email_forwarders email_quota ftps subdomains'); $row = str_replace_array('-1', 'UL', $row, 'customers domains diskspace traffic mysqls emails email_accounts email_forwarders email_quota ftps subdomains tickets');
$row = \Froxlor\PhpHelper::htmlentitiesArray($row); $row = htmlentities_array($row);
$row['custom_notes'] = ($row['custom_notes'] != '') ? nl2br($row['custom_notes']) : ''; $row['custom_notes'] = ($row['custom_notes'] != '') ? nl2br($row['custom_notes']) : '';
eval("\$admins.=\"" . \Froxlor\UI\Template::getTemplate("admins/admins_admin") . "\";"); eval("\$admins.=\"" . getTemplate("admins/admins_admin") . "\";");
$count++; $count++;
} }
$i++;
}
$admincount = $numrows_admins;
eval("echo \"" . getTemplate("admins/admins") . "\";");
$admincount = $result['count'] . " / " . $paging->getEntries();
eval("echo \"" . \Froxlor\UI\Template::getTemplate("admins/admins") . "\";");
} elseif($action == 'su') { } elseif($action == 'su') {
try { $result_stmt = Database::prepare("
$json_result = Admins::getLocal($userinfo, array( SELECT * FROM `" . TABLE_PANEL_ADMINS . "` WHERE `adminid` = :adminid
'id' => $id ");
))->get(); $result = Database::pexecute_first($result_stmt, array('adminid' => $id));
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($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['adminid'] != $userinfo['userid']
) {
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
SELECT * FROM `" . TABLE_PANEL_SESSIONS . "` WHERE `userid` = :userid SELECT * FROM `" . TABLE_PANEL_SESSIONS . "` WHERE `userid` = :userid
"); ");
$result = Database::pexecute_first($result_stmt, array( $result = Database::pexecute_first($result_stmt, array('userid' => $userinfo['userid']));
'userid' => $userinfo['userid']
));
$s = \Froxlor\Froxlor::genSessionId(); $s = md5(uniqid(microtime(), 1));
$ins_stmt = Database::prepare(" $ins_stmt = Database::prepare("
INSERT INTO `" . TABLE_PANEL_SESSIONS . "` SET INSERT INTO `" . TABLE_PANEL_SESSIONS . "` SET
`hash` = :hash, `userid` = :userid, `ipaddress` = :ip, `hash` = :hash, `userid` = :userid, `ipaddress` = :ip,
@@ -145,201 +137,736 @@ if ($page == 'admins' && $userinfo['change_serversettings'] == '1') {
'lang' => $result['language'] 'lang' => $result['language']
); );
Database::pexecute($ins_stmt, $ins_data); Database::pexecute($ins_stmt, $ins_data);
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "switched adminuser and is now '" . $destination_admin . "'"); $log->logAction(ADM_ACTION, LOG_INFO, "switched adminuser and is now '" . $destination_admin . "'");
\Froxlor\UI\Response::redirectTo('admin_index.php', array( redirectTo('admin_index.php', array('s' => $s));
's' => $s
));
} else { } else {
\Froxlor\UI\Response::redirectTo('index.php', array( redirectTo('index.php', array('action' => 'login'));
'action' => 'login'
));
} }
} elseif ($action == 'delete' && $id != 0) {
try { } elseif ($action == 'delete'
$json_result = Admins::getLocal($userinfo, array( && $id != 0
'id' => $id ) {
))->get(); $result_stmt = Database::prepare("
} catch (Exception $e) { SELECT * FROM `" . TABLE_PANEL_ADMINS . "` WHERE `adminid` = :adminid
\Froxlor\UI\Response::dynamic_error($e->getMessage()); ");
} $result = Database::pexecute_first($result_stmt, array('adminid' => $id));
$result = json_decode($json_result, true)['data'];
if ($result['loginname'] != '') { if ($result['loginname'] != '') {
if ($result['adminid'] == $userinfo['userid']) { if ($result['adminid'] == $userinfo['userid']) {
\Froxlor\UI\Response::standard_error('youcantdeleteyourself'); standard_error('youcantdeleteyourself');
} }
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send'])
Admins::getLocal($userinfo, array( && $_POST['send'] == 'send'
'id' => $id ) {
))->delete(); $del_stmt = Database::prepare("
\Froxlor\UI\Response::redirectTo($filename, array( DELETE FROM `" . TABLE_PANEL_ADMINS . "` WHERE `adminid` = :adminid
'page' => $page, ");
's' => $s Database::pexecute($del_stmt, array('adminid' => $id));
));
$del_stmt = Database::prepare("
DELETE FROM `" . TABLE_PANEL_TRAFFIC_ADMINS . "` WHERE `adminid` = :adminid
");
Database::pexecute($del_stmt, array('adminid' => $id));
$del_stmt = Database::prepare("
DELETE FROM `" . TABLE_PANEL_DISKSPACE_ADMINS . "` WHERE `adminid` = :adminid
");
Database::pexecute($del_stmt, array('adminid' => $id));
$upd_stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET
`adminid` = :userid WHERE `adminid` = :adminid
");
Database::pexecute($upd_stmt, array('userid' => $userinfo['userid'], 'adminid' => $id));
$upd_stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_DOMAINS . "` SET
`adminid` = :userid WHERE `adminid` = :adminid
");
Database::pexecute($upd_stmt, array('userid' => $userinfo['userid'], 'adminid' => $id));
$log->logAction(ADM_ACTION, LOG_INFO, "deleted admin '" . $result['loginname'] . "'");
updateCounters();
redirectTo($filename, array('page' => $page, 's' => $s));
} else { } else {
\Froxlor\UI\HTML::askYesNo('admin_admin_reallydelete', $filename, array( ask_yesno('admin_admin_reallydelete', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $result['loginname']);
'id' => $id,
'page' => $page,
'action' => $action
), $result['loginname']);
} }
} }
} elseif($action == 'add') { } elseif($action == 'add') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send'])
try { && $_POST['send'] == 'send'
Admins::getLocal($userinfo, $_POST)->add(); ) {
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage()); $name = validate($_POST['name'], 'name');
$email = $idna_convert->encode(validate($_POST['email'], 'email'));
$custom_notes = validate(str_replace("\r\n", "\n", $_POST['custom_notes']), 'custom_notes', '/^[^\0]*$/');
$custom_notes_show = 0;
if (isset($_POST['custom_notes_show'])) {
$custom_notes_show = intval_ressource($_POST['custom_notes_show']);
} }
\Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page, $loginname = validate($_POST['loginname'], 'loginname');
's' => $s $password = validate($_POST['admin_password'], 'password');
)); $password = validatePassword($password);
$def_language = validate($_POST['def_language'], 'default language');
$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::Get('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;
}
if (Settings::Get('ticket.enabled') == 1) {
$tickets = intval_ressource($_POST['tickets']);
if (isset($_POST['tickets_ul'])) {
$tickets = -1;
}
} else {
$tickets = 0;
}
$mysqls = intval_ressource($_POST['mysqls']);
if (isset($_POST['mysqls_ul'])) {
$mysqls = -1;
}
$customers_see_all = 0;
if (isset($_POST['customers_see_all'])) {
$customers_see_all = intval($_POST['customers_see_all']);
}
$domains_see_all = 0;
if (isset($_POST['domains_see_all'])) {
$domains_see_all = intval($_POST['domains_see_all']);
}
$caneditphpsettings = 0;
if (isset($_POST['caneditphpsettings'])) {
$caneditphpsettings = intval($_POST['caneditphpsettings']);
}
$change_serversettings = 0;
if (isset($_POST['change_serversettings'])) {
$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;
}
$tickets_see_all = 0;
if (isset($_POST['tickets_see_all'])) {
$tickets_see_all = intval($_POST['tickets_see_all']);
}
$diskspace = $diskspace * 1024;
$traffic = $traffic * 1024 * 1024;
$ipaddress = intval_ressource($_POST['ipaddress']);
// Check if the account already exists
$loginname_check_stmt = Database::prepare("
SELECT `loginname` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `loginname` = :login
");
$loginname_check = Database::pexecute_first($loginname_check_stmt, array('login' => $loginname));
$loginname_check_admin_stmt = Database::prepare("
SELECT `loginname` FROM `" . TABLE_PANEL_ADMINS . "` WHERE `loginname` = :login
");
$loginname_check_admin = Database::pexecute_first($loginname_check_admin_stmt, array('login' => $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::Get('customer.accountprefix'), '/') . '([0-9]+)/', $loginname)) {
standard_error('loginnameissystemaccount', Settings::Get('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';
}
if ($tickets_see_all != '1') {
$tickets_see_all = '0';
}
$_theme = Settings::Get('panel.default_theme');
$ins_data = array(
'loginname' => $loginname,
'password' => makeCryptPassword($password),
'name' => $name,
'email' => $email,
'lang' => $def_language,
'change_serversettings' => $change_serversettings,
'customers' => $customers,
'customers_see_all' => $customers_see_all,
'domains' => $domains,
'domains_see_all' => $domains_see_all,
'caneditphpsettings' => $caneditphpsettings,
'diskspace' => $diskspace,
'traffic' => $traffic,
'subdomains' => $subdomains,
'emails' => $emails,
'accounts' => $email_accounts,
'forwarders' => $email_forwarders,
'quota' => $email_quota,
'ftps' => $ftps,
'tickets' => $tickets,
'tickets_see_all' => $tickets_see_all,
'mysqls' => $mysqls,
'ip' => $ipaddress,
'theme' => $_theme,
'custom_notes' => $custom_notes,
'custom_notes_show' => $custom_notes_show
);
$ins_stmt = Database::prepare("
INSERT INTO `" . TABLE_PANEL_ADMINS . "` SET
`loginname` = :loginname,
`password` = :password,
`name` = :name,
`email` = :email,
`def_language` = :lang,
`change_serversettings` = :change_serversettings,
`customers` = :customers,
`customers_see_all` = :customers_see_all,
`domains` = :domains,
`domains_see_all` = :domains_see_all,
`caneditphpsettings` = :caneditphpsettings,
`diskspace` = :diskspace,
`traffic` = :traffic,
`subdomains` = :subdomains,
`emails` = :emails,
`email_accounts` = :accounts,
`email_forwarders` = :forwarders,
`email_quota` = :quota,
`ftps` = :ftps,
`tickets` = :tickets,
`tickets_see_all` = :tickets_see_all,
`mysqls` = :mysqls,
`ip` = :ip,
`theme` = :theme,
`custom_notes` = :custom_notes,
`custom_notes_show` = :custom_notes_show
");
Database::pexecute($ins_stmt, $ins_data);
$adminid = Database::lastInsertId();
$log->logAction(ADM_ACTION, LOG_INFO, "added admin '" . $loginname . "'");
redirectTo($filename, array('page' => $page, 's' => $s));
}
} else { } else {
$language_options = ''; $language_options = '';
foreach ($languages as $language_file => $language_name) { foreach ($languages as $language_file => $language_name) {
$language_options .= \Froxlor\UI\HTML::makeoption($language_name, $language_file, $userinfo['language'], true); $language_options.= makeoption($language_name, $language_file, $userinfo['language'], true);
} }
$ipaddress = \Froxlor\UI\HTML::makeoption($lng['admin']['allips'], "-1"); $ipaddress = makeoption($lng['admin']['allips'], "-1");
$ipsandports_stmt = Database::query(" $ipsandports_stmt = Database::query("
SELECT `id`, `ip` FROM `" . TABLE_PANEL_IPSANDPORTS . "` GROUP BY `ip` ORDER BY `ip` ASC SELECT `id`, `ip` FROM `" . TABLE_PANEL_IPSANDPORTS . "` GROUP BY `ip` ORDER BY `ip` ASC
"); ");
while ($row = $ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row = $ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) {
$ipaddress .= \Froxlor\UI\HTML::makeoption($row['ip'], $row['id']); $ipaddress.= makeoption($row['ip'], $row['id']);
} }
$customers_ul = \Froxlor\UI\HTML::makecheckbox('customers_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); $customers_ul = makecheckbox('customers_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$diskspace_ul = \Froxlor\UI\HTML::makecheckbox('diskspace_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); $diskspace_ul = makecheckbox('diskspace_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$traffic_ul = \Froxlor\UI\HTML::makecheckbox('traffic_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); $traffic_ul = makecheckbox('traffic_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$domains_ul = \Froxlor\UI\HTML::makecheckbox('domains_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); $domains_ul = makecheckbox('domains_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$subdomains_ul = \Froxlor\UI\HTML::makecheckbox('subdomains_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); $subdomains_ul = makecheckbox('subdomains_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$emails_ul = \Froxlor\UI\HTML::makecheckbox('emails_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); $emails_ul = makecheckbox('emails_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$email_accounts_ul = \Froxlor\UI\HTML::makecheckbox('email_accounts_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); $email_accounts_ul = makecheckbox('email_accounts_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$email_forwarders_ul = \Froxlor\UI\HTML::makecheckbox('email_forwarders_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); $email_forwarders_ul = makecheckbox('email_forwarders_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$email_quota_ul = \Froxlor\UI\HTML::makecheckbox('email_quota_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); $email_quota_ul = makecheckbox('email_quota_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$ftps_ul = \Froxlor\UI\HTML::makecheckbox('ftps_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); $ftps_ul = makecheckbox('ftps_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$mysqls_ul = \Froxlor\UI\HTML::makecheckbox('mysqls_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); $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);
$admin_add_data = include_once dirname(__FILE__).'/lib/formfields/admin/admin/formfield.admin_add.php'; $admin_add_data = include_once dirname(__FILE__).'/lib/formfields/admin/admin/formfield.admin_add.php';
$admin_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($admin_add_data); $admin_add_form = htmlform::genHTMLForm($admin_add_data);
$title = $admin_add_data['admin_add']['title']; $title = $admin_add_data['admin_add']['title'];
$image = $admin_add_data['admin_add']['image']; $image = $admin_add_data['admin_add']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate("admins/admins_add") . "\";"); eval("echo \"" . getTemplate("admins/admins_add") . "\";");
} }
} elseif ($action == 'edit' && $id != 0) {
try { } elseif($action == 'edit'
$json_result = Admins::getLocal($userinfo, array( && $id != 0
'id' => $id ) {
))->get();
} catch (Exception $e) { $result_stmt = Database::prepare("
\Froxlor\UI\Response::dynamic_error($e->getMessage()); SELECT * FROM `" . TABLE_PANEL_ADMINS . "` WHERE `adminid` = :adminid
} ");
$result = json_decode($json_result, true)['data']; $result = Database::pexecute_first($result_stmt, array('adminid' => $id));
if ($result['loginname'] != '') { if ($result['loginname'] != '') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send'])
try { && $_POST['send'] == 'send'
Admins::getLocal($userinfo, $_POST)->update(); ) {
} catch (Exception $e) { $name = validate($_POST['name'], 'name');
\Froxlor\UI\Response::dynamic_error($e->getMessage()); $email = $idna_convert->encode(validate($_POST['email'], 'email'));
$custom_notes = validate(str_replace("\r\n", "\n", $_POST['custom_notes']), 'custom_notes', '/^[^\0]*$/');
$custom_notes_show = $result['custom_notes_show'];
if (isset($_POST['custom_notes_show'])) {
$custom_notes_show = intval_ressource($_POST['custom_notes_show']);
} }
\Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page, if ($result['adminid'] == $userinfo['userid']) {
's' => $s
)); $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'];
$tickets_see_all = $result['tickets_see_all'];
$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'];
} else {
$password = validate($_POST['admin_password'], 'new password');
$def_language = validate($_POST['def_language'], 'default language');
$deactivated = isset($_POST['deactivated']) ? 1 : 0;
$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::Get('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;
}
if (Settings::Get('ticket.enabled') == 1) {
$tickets = intval_ressource($_POST['tickets']);
if (isset($_POST['tickets_ul'])) {
$tickets = -1;
}
} else {
$tickets = 0;
}
$mysqls = intval_ressource($_POST['mysqls']);
if (isset($_POST['mysqls_ul'])) {
$mysqls = -1;
}
$customers_see_all = 0;
if (isset($_POST['customers_see_all'])) {
$customers_see_all = intval($_POST['customers_see_all']);
}
$domains_see_all = 0;
if (isset($_POST['domains_see_all'])) {
$domains_see_all = intval($_POST['domains_see_all']);
}
$caneditphpsettings = 0;
if (isset($_POST['caneditphpsettings'])) {
$caneditphpsettings = intval($_POST['caneditphpsettings']);
}
$change_serversettings = 0;
if (isset($_POST['change_serversettings'])) {
$change_serversettings = isset($_POST['change_serversettings']) ? 1 : 0;
}
$tickets_see_all = 0;
if (isset($_POST['tickets_see_all'])) {
$tickets_see_all = intval($_POST['tickets_see_all']);
}
$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 = validatePassword($password);
$password = makeCryptPassword($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';
}
if ($tickets_see_all != '1') {
$tickets_see_all = '0';
}
// check if a resource was set to something lower
// than actually used by the admin/reseller
$res_warning = "";
if ($customers != $result['customers'] && $customers != -1 && $customers < $result['customers_used']) {
$res_warning .= sprintf($lng['error']['setlessthanalreadyused'], 'customers');
}
if ($domains != $result['domains'] && $domains != -1 && $domains < $result['domains_used']) {
$res_warning .= sprintf($lng['error']['setlessthanalreadyused'], 'domains');
}
if ($diskspace != $result['diskspace'] && ($diskspace / 1024) != -1 && $diskspace < $result['diskspace_used']) {
$res_warning .= sprintf($lng['error']['setlessthanalreadyused'], 'diskspace');
}
if ($traffic != $result['traffic'] && ($traffic / 1024 / 1024) != -1 && $traffic < $result['traffic_used']) {
$res_warning .= sprintf($lng['error']['setlessthanalreadyused'], 'traffic');
}
if ($emails != $result['emails'] && $emails != -1 && $emails < $result['emails_used']) {
$res_warning .= sprintf($lng['error']['setlessthanalreadyused'], 'emails');
}
if ($email_accounts != $result['email_accounts'] && $email_accounts != -1 && $email_accounts < $result['email_accounts_used']) {
$res_warning .= sprintf($lng['error']['setlessthanalreadyused'], 'email accounts');
}
if ($email_forwarders != $result['email_forwarders'] && $email_forwarders != -1 && $email_forwarders < $result['email_forwarders_used']) {
$res_warning .= sprintf($lng['error']['setlessthanalreadyused'], 'email forwarders');
}
if ($email_quota != $result['email_quota'] && $email_quota != -1 && $email_quota < $result['email_quota_used']) {
$res_warning .= sprintf($lng['error']['setlessthanalreadyused'], 'email quota');
}
if ($ftps != $result['ftps'] && $ftps != -1 && $ftps < $result['ftps_used']) {
$res_warning .= sprintf($lng['error']['setlessthanalreadyused'], 'ftps');
}
if ($tickets != $result['tickets'] && $tickets != -1 && $tickets < $result['tickets_used']) {
$res_warning .= sprintf($lng['error']['setlessthanalreadyused'], 'tickets');
}
if ($mysqls != $result['mysqls'] && $mysqls != -1 && $mysqls < $result['mysqls_used']) {
$res_warning .= sprintf($lng['error']['setlessthanalreadyused'], 'mysqls');
}
if ($res_warning != "") {
$link = '';
$error = $res_warning;
eval("echo \"" . getTemplate('misc/error', '1') . "\";");
exit;
}
$upd_data = array(
'password' => $password,
'name' => $name,
'email' => $email,
'lang' => $def_language,
'change_serversettings' => $change_serversettings,
'customers' => $customers,
'customers_see_all' => $customers_see_all,
'domains' => $domains,
'domains_see_all' => $domains_see_all,
'caneditphpsettings' => $caneditphpsettings,
'diskspace' => $diskspace,
'traffic' => $traffic,
'subdomains' => $subdomains,
'emails' => $emails,
'accounts' => $email_accounts,
'forwarders' => $email_forwarders,
'quota' => $email_quota,
'ftps' => $ftps,
'tickets' => $tickets,
'tickets_see_all' => $tickets_see_all,
'mysqls' => $mysqls,
'ip' => $ipaddress,
'deactivated' => $deactivated,
'custom_notes' => $custom_notes,
'custom_notes_show' => $custom_notes_show,
'adminid' => $id
);
$upd_stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_ADMINS . "` SET
`password` = :password,
`name` = :name,
`email` = :email,
`def_language` = :lang,
`change_serversettings` = :change_serversettings,
`customers` = :customers,
`customers_see_all` = :customers_see_all,
`domains` = :domains,
`domains_see_all` = :domains_see_all,
`caneditphpsettings` = :caneditphpsettings,
`diskspace` = :diskspace,
`traffic` = :traffic,
`subdomains` = :subdomains,
`emails` = :emails,
`email_accounts` = :accounts,
`email_forwarders` = :forwarders,
`email_quota` = :quota,
`ftps` = :ftps,
`tickets` = :tickets,
`tickets_see_all` = :tickets_see_all,
`mysqls` = :mysqls,
`ip` = :ip,
`deactivated` = :deactivated,
`custom_notes` = :custom_notes,
`custom_notes_show` = :custom_notes_show
WHERE `adminid` = :adminid
");
Database::pexecute($upd_stmt, $upd_data);
$log->logAction(ADM_ACTION, LOG_INFO, "edited admin '#" . $id . "'");
redirectTo($filename, array('page' => $page, 's' => $s));
}
} else { } else {
$dec_places = Settings::Get('panel.decimal_places'); $dec_places = Settings::Get('panel.decimal_places');
$result['traffic'] = round($result['traffic'] / (1024 * 1024), $dec_places); $result['traffic'] = round($result['traffic'] / (1024 * 1024), $dec_places);
$result['diskspace'] = round($result['diskspace'] / 1024, $dec_places); $result['diskspace'] = round($result['diskspace'] / 1024, $dec_places);
$result['email'] = $idna_convert->decode($result['email'] ?? ''); $result['email'] = $idna_convert->decode($result['email']);
$customers_ul = \Froxlor\UI\HTML::makecheckbox('customers_ul', $lng['customer']['unlimited'], '-1', false, $result['customers'], true, true); $customers_ul = makecheckbox('customers_ul', $lng['customer']['unlimited'], '-1', false, $result['customers'], true, true);
if ($result['customers'] == '-1') { if ($result['customers'] == '-1') {
$result['customers'] = ''; $result['customers'] = '';
} }
$diskspace_ul = \Froxlor\UI\HTML::makecheckbox('diskspace_ul', $lng['customer']['unlimited'], '-1', false, $result['diskspace'], true, true); $diskspace_ul = makecheckbox('diskspace_ul', $lng['customer']['unlimited'], '-1', false, $result['diskspace'], true, true);
if ($result['diskspace'] == '-1') { if ($result['diskspace'] == '-1') {
$result['diskspace'] = ''; $result['diskspace'] = '';
} }
$traffic_ul = \Froxlor\UI\HTML::makecheckbox('traffic_ul', $lng['customer']['unlimited'], '-1', false, $result['traffic'], true, true); $traffic_ul = makecheckbox('traffic_ul', $lng['customer']['unlimited'], '-1', false, $result['traffic'], true, true);
if ($result['traffic'] == '-1') { if ($result['traffic'] == '-1') {
$result['traffic'] = ''; $result['traffic'] = '';
} }
$domains_ul = \Froxlor\UI\HTML::makecheckbox('domains_ul', $lng['customer']['unlimited'], '-1', false, $result['domains'], true, true); $domains_ul = makecheckbox('domains_ul', $lng['customer']['unlimited'], '-1', false, $result['domains'], true, true);
if ($result['domains'] == '-1') { if ($result['domains'] == '-1') {
$result['domains'] = ''; $result['domains'] = '';
} }
$subdomains_ul = \Froxlor\UI\HTML::makecheckbox('subdomains_ul', $lng['customer']['unlimited'], '-1', false, $result['subdomains'], true, true); $subdomains_ul = makecheckbox('subdomains_ul', $lng['customer']['unlimited'], '-1', false, $result['subdomains'], true, true);
if ($result['subdomains'] == '-1') { if ($result['subdomains'] == '-1') {
$result['subdomains'] = ''; $result['subdomains'] = '';
} }
$emails_ul = \Froxlor\UI\HTML::makecheckbox('emails_ul', $lng['customer']['unlimited'], '-1', false, $result['emails'], true, true); $emails_ul = makecheckbox('emails_ul', $lng['customer']['unlimited'], '-1', false, $result['emails'], true, true);
if ($result['emails'] == '-1') { if ($result['emails'] == '-1') {
$result['emails'] = ''; $result['emails'] = '';
} }
$email_accounts_ul = \Froxlor\UI\HTML::makecheckbox('email_accounts_ul', $lng['customer']['unlimited'], '-1', false, $result['email_accounts'], true, true); $email_accounts_ul = makecheckbox('email_accounts_ul', $lng['customer']['unlimited'], '-1', false, $result['email_accounts'], true, true);
if ($result['email_accounts'] == '-1') { if ($result['email_accounts'] == '-1') {
$result['email_accounts'] = ''; $result['email_accounts'] = '';
} }
$email_forwarders_ul = \Froxlor\UI\HTML::makecheckbox('email_forwarders_ul', $lng['customer']['unlimited'], '-1', false, $result['email_forwarders'], true, true); $email_forwarders_ul = makecheckbox('email_forwarders_ul', $lng['customer']['unlimited'], '-1', false, $result['email_forwarders'], true, true);
if ($result['email_forwarders'] == '-1') { if ($result['email_forwarders'] == '-1') {
$result['email_forwarders'] = ''; $result['email_forwarders'] = '';
} }
$email_quota_ul = \Froxlor\UI\HTML::makecheckbox('email_quota_ul', $lng['customer']['unlimited'], '-1', false, $result['email_quota'], true, true); $email_quota_ul = makecheckbox('email_quota_ul', $lng['customer']['unlimited'], '-1', false, $result['email_quota'], true, true);
if ($result['email_quota'] == '-1') { if ($result['email_quota'] == '-1') {
$result['email_quota'] = ''; $result['email_quota'] = '';
} }
$ftps_ul = \Froxlor\UI\HTML::makecheckbox('ftps_ul', $lng['customer']['unlimited'], '-1', false, $result['ftps'], true, true); $ftps_ul = makecheckbox('ftps_ul', $lng['customer']['unlimited'], '-1', false, $result['ftps'], true, true);
if ($result['ftps'] == '-1') { if ($result['ftps'] == '-1') {
$result['ftps'] = ''; $result['ftps'] = '';
} }
$mysqls_ul = \Froxlor\UI\HTML::makecheckbox('mysqls_ul', $lng['customer']['unlimited'], '-1', false, $result['mysqls'], true, true); $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') { if ($result['mysqls'] == '-1') {
$result['mysqls'] = ''; $result['mysqls'] = '';
} }
$language_options = ''; $language_options = '';
foreach ($languages as $language_file => $language_name) { foreach ($languages as $language_file => $language_name) {
$language_options .= \Froxlor\UI\HTML::makeoption($language_name, $language_file, $result['def_language'], true); $language_options.= makeoption($language_name, $language_file, $result['def_language'], true);
} }
$ipaddress = \Froxlor\UI\HTML::makeoption($lng['admin']['allips'], "-1", $result['ip']); $ipaddress = makeoption($lng['admin']['allips'], "-1", $result['ip']);
$ipsandports_stmt = Database::query(" $ipsandports_stmt = Database::query("
SELECT `id`, `ip` FROM `" . TABLE_PANEL_IPSANDPORTS . "` GROUP BY `id`, `ip` ORDER BY `ip`, `port` ASC SELECT `id`, `ip` FROM `" . TABLE_PANEL_IPSANDPORTS . "` GROUP BY `id`, `ip` ORDER BY `ip`, `port` ASC
"); ");
while ($row = $ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row = $ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) {
$ipaddress .= \Froxlor\UI\HTML::makeoption($row['ip'], $row['id'], $result['ip']); $ipaddress.= makeoption($row['ip'], $row['id'], $result['ip']);
} }
$result = \Froxlor\PhpHelper::htmlentitiesArray($result); $result = htmlentities_array($result);
$admin_edit_data = include_once dirname(__FILE__).'/lib/formfields/admin/admin/formfield.admin_edit.php'; $admin_edit_data = include_once dirname(__FILE__).'/lib/formfields/admin/admin/formfield.admin_edit.php';
$admin_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($admin_edit_data); $admin_edit_form = htmlform::genHTMLForm($admin_edit_data);
$title = $admin_edit_data['admin_edit']['title']; $title = $admin_edit_data['admin_edit']['title'];
$image = $admin_edit_data['admin_edit']['image']; $image = $admin_edit_data['admin_edit']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate("admins/admins_edit") . "\";"); eval("echo \"" . getTemplate("admins/admins_edit") . "\";");
} }
} }
} }

View File

@@ -1,54 +1,59 @@
<?php <?php
/* /*
* +----------------------------------------------------------------------+ +----------------------------------------------------------------------+
* | APC | | APC |
* +----------------------------------------------------------------------+ +----------------------------------------------------------------------+
* | Copyright (c) 2006-2011 The PHP Group | | Copyright (c) 2006-2011 The PHP Group |
* +----------------------------------------------------------------------+ +----------------------------------------------------------------------+
* | This source file is subject to version 3.01 of the PHP license, | | This source file is subject to version 3.01 of the PHP license, |
* | that is bundled with this package in the file LICENSE, and is | | that is bundled with this package in the file LICENSE, and is |
* | available through the world-wide-web at the following url: | | available through the world-wide-web at the following url: |
* | http://www.php.net/license/3_01.txt | | http://www.php.net/license/3_01.txt |
* | If you did not receive a copy of the PHP license and are unable to | | If you did not receive a copy of the PHP license and are unable to |
* | obtain it through the world-wide-web, please send a note to | | obtain it through the world-wide-web, please send a note to |
* | license@php.net so we can mail you a copy immediately. | | license@php.net so we can mail you a copy immediately. |
* +----------------------------------------------------------------------+ +----------------------------------------------------------------------+
* | Authors: Ralf Becker <beckerr@php.net> | | Authors: Ralf Becker <beckerr@php.net> |
* | Rasmus Lerdorf <rasmus@php.net> | | Rasmus Lerdorf <rasmus@php.net> |
* | Ilia Alshanetsky <ilia@prohost.org> | | Ilia Alshanetsky <ilia@prohost.org> |
* +----------------------------------------------------------------------+ +----------------------------------------------------------------------+
*
* All other licensing and usage conditions are those of the PHP Group. All other licensing and usage conditions are those of the PHP Group.
*
* Based on https://github.com/krakjoe/apcu/blob/master/apc.php Based on https://github.com/krakjoe/apcu/blob/master/apc.php
* Implemented into Froxlor: Janos Muzsi <muzsij@hypernics.hu> Implemented into Froxlor: Janos Muzsi <muzsij@hypernics.hu>
*
*/ */
define('AREA', 'admin'); define('AREA', 'admin');
require './lib/init.php'; require './lib/init.php';
$horizontal_bar_size = 950; // 1280px window width $horizontal_bar_size = 950; // 1280px window width
if ($action == 'delete' && function_exists('apcu_clear_cache') && $userinfo['change_serversettings'] == '1') { if ($action == 'delete' &&
function_exists('apcu_clear_cache') &&
$userinfo['change_serversettings'] == '1'
) {
apcu_clear_cache(); apcu_clear_cache();
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "cleared APCu cache"); $log->logAction(ADM_ACTION, LOG_INFO, "cleared APCu cache");
header('Location: ' . $linker->getLink(array( header('Location: ' . $linker->getLink(array('section' => 'apcuinfo', 'page' => 'showinfo')));
'section' => 'apcuinfo',
'page' => 'showinfo'
)));
exit(); exit();
} }
if (! function_exists('apcu_cache_info') || ! function_exists('apcu_sma_info')) { if (!function_exists('apcu_cache_info') ||
\Froxlor\UI\Response::standard_error($lng['error']['no_apcuinfo']); !function_exists('apcu_sma_info')
) {
standard_error($lng['error']['no_apcuinfo']);
} }
if ($page == 'showinfo') { if ($page == 'showinfo'
) {
$cache = apcu_cache_info(); $cache = apcu_cache_info();
$mem = apcu_sma_info(); $mem = apcu_sma_info();
$time = time(); $time = time();
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_apcuinfo"); $log->logAction(ADM_ACTION, LOG_NOTICE, "viewed admin_apcuinfo");
$passtime = $time - $cache['start_time'] > 0 ? $time - $cache['start_time'] : 1; // zero division $passtime = $time - $cache['start_time'] > 0 ? $time - $cache['start_time'] : 1; // zero division
$mem_size = $mem['num_seg'] * $mem['seg_size']; $mem_size = $mem['num_seg'] * $mem['seg_size'];
@@ -67,9 +72,6 @@ if ($page == 'showinfo') {
$uptime_duration = duration($cache['start_time']); $uptime_duration = duration($cache['start_time']);
$size_vars = bsize($cache['mem_size']); $size_vars = bsize($cache['mem_size']);
$num_hits_and_misses = $cache['num_hits'] + $cache['num_misses'];
$num_hits_and_misses = 0 >= $num_hits_and_misses ? 1 : $num_hits_and_misses;
// check for possible empty values that are used in the templates // check for possible empty values that are used in the templates
if (!isset($cache['file_upload_progress'])) { if (!isset($cache['file_upload_progress'])) {
$cache['file_upload_progress'] = $lng['logger']['unknown']; $cache['file_upload_progress'] = $lng['logger']['unknown'];
@@ -82,15 +84,15 @@ if ($page == 'showinfo') {
$runtimelines = ''; $runtimelines = '';
foreach (ini_get_all('apcu') as $name => $v) { foreach (ini_get_all('apcu') as $name => $v) {
$value = $v['local_value']; $value = $v['local_value'];
eval("\$runtimelines.=\"" . \Froxlor\UI\Template::getTemplate("settings/apcuinfo/runtime_line") . "\";"); eval("\$runtimelines.=\"" . getTemplate("settings/apcuinfo/runtime_line") . "\";");
} }
$freemem = bsize($mem_avail) . sprintf(" (%.1f%%)", $mem_avail * 100 / $mem_size); $freemem = bsize($mem_avail) . sprintf(" (%.1f%%)", $mem_avail * 100 / $mem_size);
$usedmem = bsize($mem_used) . sprintf(" (%.1f%%)", $mem_used * 100 / $mem_size); $usedmem = bsize($mem_used) . sprintf(" (%.1f%%)", $mem_used * 100 / $mem_size);
$hits = $cache['num_hits'] . @sprintf(" (%.1f%%)", $cache['num_hits'] * 100 / $num_hits_and_misses); $hits = $cache['num_hits'] . @sprintf(" (%.1f%%)", $cache['num_hits'] * 100 / ($cache['num_hits'] + $cache['num_misses']));
$misses = $cache['num_misses'] . @sprintf(" (%.1f%%)", $cache['num_misses'] * 100 / $num_hits_and_misses); $misses = $cache['num_misses'] . @sprintf(" (%.1f%%)", $cache['num_misses'] * 100 / ($cache['num_hits'] + $cache['num_misses']));
// Fragmentation: (freeseg - 1) / total_seg // Fragementation: (freeseg - 1) / total_seg
$nseg = $freeseg = $fragsize = $freetotal = 0; $nseg = $freeseg = $fragsize = $freetotal = 0;
for ($i = 0; $i < $mem['num_seg']; $i++) { for ($i = 0; $i < $mem['num_seg']; $i++) {
$ptr = 0; $ptr = 0;
@@ -121,28 +123,18 @@ if ($page == 'showinfo') {
$img_src2 = ''; $img_src2 = '';
$img_src3 = ''; $img_src3 = '';
if (graphics_avail()) { if (graphics_avail()) {
$img_src = $linker->getLink(array( $img_src = $linker->getLink(array('section' => 'apcuinfo', 'page' => 'img1', 'action' => mt_rand(0, 1000000)));
'section' => 'apcuinfo', eval("\$img_src1=\"" . getTemplate("settings/apcuinfo/img_line") . "\";");
'page' => 'img1', $img_src = $linker->getLink(array('section' => 'apcuinfo', 'page' => 'img2', 'action' => mt_rand(0, 1000000)));
'action' => mt_rand(0, 1000000) eval("\$img_src2=\"" . getTemplate("settings/apcuinfo/img_line") . "\";");
)); $img_src = $linker->getLink(array('section' => 'apcuinfo', 'page' => 'img3', 'action' => mt_rand(0, 1000000)));
eval("\$img_src1=\"" . \Froxlor\UI\Template::getTemplate("settings/apcuinfo/img_line") . "\";"); eval("\$img_src3=\"" . getTemplate("settings/apcuinfo/img_line") . "\";");
$img_src = $linker->getLink(array(
'section' => 'apcuinfo',
'page' => 'img2',
'action' => mt_rand(0, 1000000)
));
eval("\$img_src2=\"" . \Froxlor\UI\Template::getTemplate("settings/apcuinfo/img_line") . "\";");
$img_src = $linker->getLink(array(
'section' => 'apcuinfo',
'page' => 'img3',
'action' => mt_rand(0, 1000000)
));
eval("\$img_src3=\"" . \Froxlor\UI\Template::getTemplate("settings/apcuinfo/img_line") . "\";");
} }
eval("echo \"" . \Froxlor\UI\Template::getTemplate("settings/apcuinfo/showinfo") . "\";"); eval("echo \"" . getTemplate("settings/apcuinfo/showinfo") . "\";");
} elseif ($page == 'img1') {
} elseif ($page == 'img1'
) {
$mem = apcu_sma_info(); $mem = apcu_sma_info();
@@ -177,10 +169,7 @@ if ($page == 'showinfo') {
if (($angle_to * 360) - ($angle_from * 360) >= 1) { if (($angle_to * 360) - ($angle_from * 360) >= 1) {
fill_arc($image, $x, $y, $size, $angle_from * 360, $angle_to * 360, $col_black, $col_red); fill_arc($image, $x, $y, $size, $angle_from * 360, $angle_to * 360, $col_black, $col_red);
if (($angle_to - $angle_from) > 0.05) { if (($angle_to - $angle_from) > 0.05) {
array_push($string_placement, array( array_push($string_placement, array($angle_from, $angle_to));
$angle_from,
$angle_to
));
} }
} }
$angle_from = $angle_to; $angle_from = $angle_to;
@@ -191,10 +180,7 @@ if ($page == 'showinfo') {
if (($angle_to * 360) - ($angle_from * 360) >= 1) { if (($angle_to * 360) - ($angle_from * 360) >= 1) {
fill_arc($image, $x, $y, $size, $angle_from * 360, $angle_to * 360, $col_black, $col_green); fill_arc($image, $x, $y, $size, $angle_from * 360, $angle_to * 360, $col_black, $col_green);
if (($angle_to - $angle_from) > 0.05) { if (($angle_to - $angle_from) > 0.05) {
array_push($string_placement, array( array_push($string_placement, array($angle_from, $angle_to));
$angle_from,
$angle_to
));
} }
} }
$angle_from = $angle_to; $angle_from = $angle_to;
@@ -206,10 +192,7 @@ if ($page == 'showinfo') {
$angle_to = 1; $angle_to = 1;
fill_arc($image, $x, $y, $size, $angle_from * 360, $angle_to * 360, $col_black, $col_red); fill_arc($image, $x, $y, $size, $angle_from * 360, $angle_to * 360, $col_black, $col_red);
if (($angle_to - $angle_from) > 0.05) { if (($angle_to - $angle_from) > 0.05) {
array_push($string_placement, array( array_push($string_placement, array($angle_from, $angle_to));
$angle_from,
$angle_to
));
} }
} }
} }
@@ -219,8 +202,9 @@ if ($page == 'showinfo') {
header("Content-type: image/png"); header("Content-type: image/png");
imagepng($image); imagepng($image);
exit(); exit;
} elseif ($page == 'img2') { } elseif ($page == 'img2'
) {
$cache = apcu_cache_info(); $cache = apcu_cache_info();
@@ -237,15 +221,14 @@ if ($page == 'showinfo') {
$s = $cache['num_hits'] + $cache['num_misses']; $s = $cache['num_hits'] + $cache['num_misses'];
$a = $cache['num_hits']; $a = $cache['num_hits'];
fill_box($image, 1, 10, $s ? ($a * ($size - 21) / $s) : $size, 50, $col_black, $col_green /* , sprintf("%.1f%%", $s ? $cache['num_hits'] * 100 / $s : 0) */ fill_box($image, 1, 10, $s ? ($a * ($size - 21) / $s) : $size, 50, $col_black, $col_green/* , sprintf("%.1f%%", $s ? $cache['num_hits'] * 100 / $s : 0) */);
); fill_box($image, 1, 80, $s ? max(4, ($s - $a) * ($size - 21) / $s) : $size, 50, $col_black, $col_red/* , sprintf("%.1f%%", $s ? $cache['num_misses'] * 100 / $s : 0) */);
fill_box($image, 1, 80, $s ? max(4, ($s - $a) * ($size - 21) / $s) : $size, 50, $col_black, $col_red /* , sprintf("%.1f%%", $s ? $cache['num_misses'] * 100 / $s : 0) */
);
header("Content-type: image/png"); header("Content-type: image/png");
imagepng($image); imagepng($image);
exit(); exit;
} elseif ($page == 'img3') { } elseif ($page == 'img3'
) {
$mem = apcu_sma_info(); $mem = apcu_sma_info();
@@ -295,24 +278,17 @@ if ($page == 'showinfo') {
header("Content-type: image/png"); header("Content-type: image/png");
imagepng($image); imagepng($image);
exit(); exit;
} }
function graphics_avail() function graphics_avail() {
{
return extension_loaded('gd'); return extension_loaded('gd');
} }
// pretty printer for byte values // pretty printer for byte values
// //
function bsize($s) function bsize($s) {
{ foreach (array('', 'K', 'M', 'G') as $i => $k) {
foreach (array(
'',
'K',
'M',
'G'
) as $i => $k) {
if ($s < 1024) if ($s < 1024)
break; break;
$s/=1024; $s/=1024;
@@ -320,8 +296,7 @@ function bsize($s)
return sprintf("%5.1f %sBytes", $s, $k); return sprintf("%5.1f %sBytes", $s, $k);
} }
function duration($ts) function duration($ts) {
{
global $time; global $time;
$years = (int) ((($time - $ts) / (7 * 86400)) / 52.177457); $years = (int) ((($time - $ts) / (7 * 86400)) / 52.177457);
$rem = (int) (($time - $ts) - ($years * 52.177457 * 7 * 86400)); $rem = (int) (($time - $ts) - ($years * 52.177457 * 7 * 86400));
@@ -353,8 +328,7 @@ function duration($ts)
return $str; return $str;
} }
function block_sort($array1, $array2) function block_sort($array1, $array2) {
{
if ($array1['offset'] > $array2['offset']) { if ($array1['offset'] > $array2['offset']) {
return 1; return 1;
} else { } else {
@@ -362,11 +336,11 @@ function block_sort($array1, $array2)
} }
} }
function fill_arc($im, $centerX, $centerY, $diameter, $start, $end, $color1, $color2, $text = '', $placeindex = 0) function fill_arc($im, $centerX, $centerY, $diameter, $start, $end, $color1, $color2, $text = '', $placeindex = 0) {
{
$r = $diameter / 2; $r = $diameter / 2;
$w = deg2rad((360 + $start + ($end - $start) / 2) % 360); $w = deg2rad((360 + $start + ($end - $start) / 2) % 360);
if (function_exists("imagefilledarc")) { if (function_exists("imagefilledarc")) {
// exists only if GD 2.0.1 is available // exists only if GD 2.0.1 is available
imagefilledarc($im, $centerX + 1, $centerY + 1, $diameter, $diameter, $start, $end, $color1, IMG_ARC_PIE); imagefilledarc($im, $centerX + 1, $centerY + 1, $diameter, $diameter, $start, $end, $color1, IMG_ARC_PIE);
@@ -390,8 +364,7 @@ function fill_arc($im, $centerX, $centerY, $diameter, $start, $end, $color1, $co
} }
} }
function text_arc($im, $centerX, $centerY, $diameter, $start, $end, $color1, $text, $placeindex = 0) function text_arc($im, $centerX, $centerY, $diameter, $start, $end, $color1, $text, $placeindex = 0) {
{
$r = $diameter / 2; $r = $diameter / 2;
$w = deg2rad((360 + $start + ($end - $start) / 2) % 360); $w = deg2rad((360 + $start + ($end - $start) / 2) % 360);
@@ -403,8 +376,7 @@ function text_arc($im, $centerX, $centerY, $diameter, $start, $end, $color1, $te
} }
} }
function fill_box($im, $x, $y, $w, $h, $color1, $color2, $text = '', $placeindex = '') function fill_box($im, $x, $y, $w, $h, $color1, $color2, $text = '', $placeindex = '') {
{
global $col_black; global $col_black;
$x1 = $x + $w - 1; $x1 = $x + $w - 1;
$y1 = $y + $h - 1; $y1 = $y + $h - 1;

View File

@@ -20,43 +20,29 @@
define('AREA', 'admin'); define('AREA', 'admin');
require './lib/init.php'; require './lib/init.php';
use Froxlor\Http\HttpClient;
// define update-uri // define update-uri
define('UPDATE_URI', "https://version.froxlor.org/Froxlor/api/" . $version); define('UPDATE_URI', "https://version.froxlor.org/Froxlor/legacy/" . $version);
define('RELEASE_URI', "https://autoupdate.froxlor.org/froxlor-{version}.zip"); define('RELEASE_URI', "https://autoupdate.froxlor.org/froxlor-{version}.zip");
define('CHECKSUM_URI', "https://autoupdate.froxlor.org/froxlor-{version}.zip.sha256"); define('CHECKSUM_URI', "https://autoupdate.froxlor.org/froxlor-{version}.zip.sha256");
// check for archive-stuff // check for archive-stuff
if (! extension_loaded('zip')) { if (! extension_loaded('zip')) {
\Froxlor\UI\Response::redirectTo($filename, array( redirectTo($filename, array(
's' => $s, 's' => $s,
'page' => 'error', 'page' => 'error',
'errno' => 2 'errno' => 2
)); ));
} }
// 0.10.x requires 7.0 at least
if (version_compare("7.0.0", PHP_VERSION, ">=")) {
\Froxlor\UI\Response::redirectTo($filename, array(
's' => $s,
'page' => 'error',
'errno' => 10
));
}
// display initial version check // display initial version check
if ($page == 'overview') { if ($page == 'overview') {
// log our actions // log our actions
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "checking auto-update"); $log->logAction(ADM_ACTION, LOG_NOTICE, "checking auto-update");
// check for new version // check for new version
try { $latestversion = HttpClient::urlGet(UPDATE_URI);
$latestversion = HttpClient::urlGet(UPDATE_URI, true, 3);
} catch (\Exception $e) {
\Froxlor\UI\Response::dynamic_error("Version-check currently unavailable, please try again later");
}
$latestversion = explode('|', $latestversion); $latestversion = explode('|', $latestversion);
if (is_array($latestversion) && count($latestversion) >= 1) { if (is_array($latestversion) && count($latestversion) >= 1) {
@@ -74,12 +60,12 @@ if ($page == 'overview') {
if (! preg_match('/^((\d+\\.)(\d+\\.)(\d+\\.)?(\d+)?(\-(svn|dev|rc)(\d+))?)$/', $_version)) { if (! preg_match('/^((\d+\\.)(\d+\\.)(\d+\\.)?(\d+)?(\-(svn|dev|rc)(\d+))?)$/', $_version)) {
// check for customized version to not output // check for customized version to not output
// "There is a newer version of froxlor" besides the error-message // "There is a newer version of froxlor" besides the error-message
\Froxlor\UI\Response::redirectTo($filename, array( redirectTo($filename, array(
's' => $s, 's' => $s,
'page' => 'error', 'page' => 'error',
'errno' => 3 'errno' => 3
)); ));
} elseif (\Froxlor\Froxlor::versionCompare2($version, $_version) == - 1) { } elseif (version_compare2($version, $_version) == - 1) {
// there is a newer version - yay // there is a newer version - yay
$isnewerversion = 1; $isnewerversion = 1;
} else { } else {
@@ -93,13 +79,13 @@ if ($page == 'overview') {
$text = 'There is a newer version available. Update to version <b>' . $_version . '</b> now?<br/>(Your current version is: ' . $version . ')'; $text = 'There is a newer version available. Update to version <b>' . $_version . '</b> now?<br/>(Your current version is: ' . $version . ')';
$hiddenparams = '<input type="hidden" name="newversion" value="' . $_version . '" />'; $hiddenparams = '<input type="hidden" name="newversion" value="' . $_version . '" />';
$yesfile = $filename . '?s=' . $s . '&amp;page=getdownload'; $yesfile = $filename . '?s=' . $s . '&amp;page=getdownload';
eval("echo \"" . \Froxlor\UI\Template::getTemplate("misc/question_yesno", true) . "\";"); eval("echo \"" . getTemplate("misc/question_yesno", true) . "\";");
exit(); exit();
} elseif ($isnewerversion == 0) { } elseif ($isnewerversion == 0) {
// all good // all good
\Froxlor\UI\Response::standard_success('noupdatesavail'); standard_success('noupdatesavail');
} else { } else {
\Froxlor\UI\Response::standard_error('customized_version'); standard_error('customized_version');
} }
} }
}// download the new archive }// download the new archive
@@ -116,14 +102,14 @@ elseif ($page == 'getdownload') {
$toCheck = str_replace('{version}', $newversion, CHECKSUM_URI); $toCheck = str_replace('{version}', $newversion, CHECKSUM_URI);
// check for local destination folder // check for local destination folder
if (! is_dir(\Froxlor\Froxlor::getInstallDir() . '/updates/')) { if (! is_dir(FROXLOR_INSTALL_DIR . '/updates/')) {
mkdir(\Froxlor\Froxlor::getInstallDir() . '/updates/'); mkdir(FROXLOR_INSTALL_DIR . '/updates/');
} }
// name archive // name archive
$localArchive = \Froxlor\Froxlor::getInstallDir() . '/updates/' . basename($toLoad); $localArchive = FROXLOR_INSTALL_DIR . '/updates/' . basename($toLoad);
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "Downloading " . $toLoad . " to " . $localArchive); $log->logAction(ADM_ACTION, LOG_NOTICE, "Downloading " . $toLoad . " to " . $localArchive);
// remove old archive // remove old archive
if (file_exists($localArchive)) { if (file_exists($localArchive)) {
@@ -134,7 +120,7 @@ elseif ($page == 'getdownload') {
try { try {
HttpClient::fileGet($toLoad, $localArchive); HttpClient::fileGet($toLoad, $localArchive);
} catch (Exception $e) { } catch (Exception $e) {
\Froxlor\UI\Response::redirectTo($filename, array( redirectTo($filename, array(
's' => $s, 's' => $s,
'page' => 'error', 'page' => 'error',
'errno' => 4 'errno' => 4
@@ -152,7 +138,7 @@ elseif ($page == 'getdownload') {
$filesum = hash_file('sha256', $localArchive); $filesum = hash_file('sha256', $localArchive);
if ($filesum != $shouldsum) { if ($filesum != $shouldsum) {
\Froxlor\UI\Response::redirectTo($filename, array( redirectTo($filename, array(
's' => $s, 's' => $s,
'page' => 'error', 'page' => 'error',
'errno' => 9 'errno' => 9
@@ -160,13 +146,13 @@ elseif ($page == 'getdownload') {
} }
// to the next step // to the next step
\Froxlor\UI\Response::redirectTo($filename, array( redirectTo($filename, array(
's' => $s, 's' => $s,
'page' => 'extract', 'page' => 'extract',
'archive' => basename($localArchive) 'archive' => basename($localArchive)
)); ));
} }
\Froxlor\UI\Response::redirectTo($filename, array( redirectTo($filename, array(
's' => $s, 's' => $s,
'page' => 'error', 'page' => 'error',
'errno' => 6 'errno' => 6
@@ -175,23 +161,21 @@ elseif ($page == 'getdownload') {
elseif ($page == 'extract') { elseif ($page == 'extract') {
$toExtract = isset($_GET['archive']) ? $_GET['archive'] : null; $toExtract = isset($_GET['archive']) ? $_GET['archive'] : null;
$localArchive = \Froxlor\Froxlor::getInstallDir() . '/updates/' . $toExtract; $localArchive = FROXLOR_INSTALL_DIR . '/updates/' . $toExtract;
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
// decompress from zip // decompress from zip
$zip = new ZipArchive(); $zip = new ZipArchive();
$res = $zip->open($localArchive); $res = $zip->open($localArchive);
if ($res === true) { if ($res === true) {
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "Extracting " . $localArchive . " to " . \Froxlor\Froxlor::getInstallDir()); $log->logAction(ADM_ACTION, LOG_NOTICE, "Extracting " . $localArchive . " to " . FROXLOR_INSTALL_DIR);
$zip->extractTo(\Froxlor\Froxlor::getInstallDir()); $zip->extractTo(FROXLOR_INSTALL_DIR);
$zip->close(); $zip->close();
// success - remove unused archive // success - remove unused archive
@unlink($localArchive); @unlink($localArchive);
// wait a bit before we redirect to be sure
sleep(2);
} else { } else {
// error // error
\Froxlor\UI\Response::redirectTo($filename, array( redirectTo($filename, array(
's' => $s, 's' => $s,
'page' => 'error', 'page' => 'error',
'errno' => 8 'errno' => 8
@@ -199,13 +183,13 @@ elseif ($page == 'extract') {
} }
// redirect to update-page? // redirect to update-page?
\Froxlor\UI\Response::redirectTo('admin_updates.php', array( redirectTo('admin_updates.php', array(
's' => $s 's' => $s
)); ));
} }
if (! file_exists($localArchive)) { if (! file_exists($localArchive)) {
\Froxlor\UI\Response::redirectTo($filename, array( redirectTo($filename, array(
's' => $s, 's' => $s,
'page' => 'error', 'page' => 'error',
'errno' => 7 'errno' => 7
@@ -215,8 +199,9 @@ elseif ($page == 'extract') {
$text = 'Extract downloaded archive "' . $toExtract . '"?'; $text = 'Extract downloaded archive "' . $toExtract . '"?';
$hiddenparams = ''; $hiddenparams = '';
$yesfile = $filename . '?s=' . $s . '&amp;page=extract&amp;archive=' . $toExtract; $yesfile = $filename . '?s=' . $s . '&amp;page=extract&amp;archive=' . $toExtract;
eval("echo \"" . \Froxlor\UI\Template::getTemplate("misc/question_yesno", true) . "\";"); eval("echo \"" . getTemplate("misc/question_yesno", true) . "\";");
} // display error }
// display error
elseif ($page == 'error') { elseif ($page == 'error') {
// retrieve error-number via url-parameter // retrieve error-number via url-parameter
@@ -230,6 +215,5 @@ elseif ($page == 'error') {
// 7 = local archive does not exist // 7 = local archive does not exist
// 8 = could not extract archive // 8 = could not extract archive
// 9 = checksum mismatch // 9 = checksum mismatch
// 10 = <php-7.0 standard_error('autoupdate_' . $errno);
\Froxlor\UI\Response::standard_error('autoupdate_' . $errno);
} }

View File

@@ -18,65 +18,29 @@
define('AREA', 'admin'); define('AREA', 'admin');
require './lib/init.php'; require './lib/init.php';
use Froxlor\Settings;
if ($userinfo['change_serversettings'] == '1') { if ($userinfo['change_serversettings'] == '1') {
if ($action == 'setconfigured') {
Settings::Set('panel.is_configured', '1', true);
\Froxlor\UI\Response::redirectTo('admin_configfiles.php', array(
's' => $s
));
}
$customer_tmpdir = '/tmp/'; $customer_tmpdir = '/tmp/';
if (Settings::Get('system.mod_fcgid') == '1' && Settings::Get('system.mod_fcgid_tmpdir') != '') { if (Settings::Get('system.mod_fcgid') == '1' && Settings::Get('system.mod_fcgid_tmpdir') != '')
{
$customer_tmpdir = Settings::Get('system.mod_fcgid_tmpdir'); $customer_tmpdir = Settings::Get('system.mod_fcgid_tmpdir');
} elseif (Settings::Get('phpfpm.enabled') == '1' && Settings::Get('phpfpm.tmpdir') != '') { }
elseif (Settings::Get('phpfpm.enabled') == '1' && Settings::Get('phpfpm.tmpdir') != '')
{
$customer_tmpdir = Settings::Get('phpfpm.tmpdir'); $customer_tmpdir = Settings::Get('phpfpm.tmpdir');
} }
// try to convert namserver hosts to ip's // try to convert namserver hosts to ip's
$ns_ips = ""; $ns_ips = "";
$known_ns_ips = [];
if (Settings::Get('system.nameservers') != '') { if (Settings::Get('system.nameservers') != '') {
$nameservers = explode(',', Settings::Get('system.nameservers')); $nameservers = explode(',', Settings::Get('system.nameservers'));
foreach ($nameservers as $nameserver) { foreach ($nameservers as $nameserver) {
$nameserver = trim($nameserver); $nameserver = trim($nameserver);
// DNS servers might be multi homed; allow transfer from all ip $nameserver_ips = gethostbynamel($nameserver);
// addresses of the DNS server if (is_array($nameserver_ips) && count($nameserver_ips) > 0) {
$nameserver_ips = \Froxlor\PhpHelper::gethostbynamel6($nameserver);
// append dot to hostname
if (substr($nameserver, - 1, 1) != '.') {
$nameserver .= '.';
}
// ignore invalid responses
if (! is_array($nameserver_ips)) {
// act like \Froxlor\PhpHelper::gethostbynamel6() and return unmodified hostname on error
$nameserver_ips = array(
$nameserver
);
} else {
$known_ns_ips = array_merge($known_ns_ips, $nameserver_ips);
}
if (!empty($ns_ips)) {
$ns_ips .= ',';
}
$ns_ips .= implode(",", $nameserver_ips); $ns_ips .= implode(",", $nameserver_ips);
} }
} }
// AXFR server
if (Settings::Get('system.axfrservers') != '') {
$axfrservers = explode(',', Settings::Get('system.axfrservers'));
foreach ($axfrservers as $axfrserver) {
if (!in_array(trim($axfrserver), $known_ns_ips)) {
if (!empty($ns_ips)) {
$ns_ips .= ',';
}
$ns_ips .= trim($axfrserver);
}
}
} }
$replace_arr = Array( $replace_arr = Array(
@@ -89,16 +53,17 @@ if ($userinfo['change_serversettings'] == '1') {
'<SERVERIP>' => Settings::Get('system.ipaddress'), '<SERVERIP>' => Settings::Get('system.ipaddress'),
'<NAMESERVERS>' => Settings::Get('system.nameservers'), '<NAMESERVERS>' => Settings::Get('system.nameservers'),
'<NAMESERVERS_IP>' => $ns_ips, '<NAMESERVERS_IP>' => $ns_ips,
'<AXFRSERVERS>' => Settings::Get('system.axfrservers'),
'<VIRTUAL_MAILBOX_BASE>' => Settings::Get('system.vmail_homedir'), '<VIRTUAL_MAILBOX_BASE>' => Settings::Get('system.vmail_homedir'),
'<VIRTUAL_UID_MAPS>' => Settings::Get('system.vmail_uid'), '<VIRTUAL_UID_MAPS>' => Settings::Get('system.vmail_uid'),
'<VIRTUAL_GID_MAPS>' => Settings::Get('system.vmail_gid'), '<VIRTUAL_GID_MAPS>' => Settings::Get('system.vmail_gid'),
'<SSLPROTOCOLS>' => (Settings::Get('system.use_ssl') == '1') ? 'imaps pop3s' : '', '<SSLPROTOCOLS>' => (Settings::Get('system.use_ssl') == '1') ? 'imaps pop3s' : '',
'<CUSTOMER_TMP>' => \Froxlor\FileDir::makeCorrectDir($customer_tmpdir), '<CUSTOMER_TMP>' => makeCorrectDir($customer_tmpdir),
'<BASE_PATH>' => \Froxlor\FileDir::makeCorrectDir(\Froxlor\Froxlor::getInstallDir()), '<BASE_PATH>' => makeCorrectDir(FROXLOR_INSTALL_DIR),
'<BIND_CONFIG_PATH>' => \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.bindconf_directory')), '<BIND_CONFIG_PATH>' => makeCorrectDir(Settings::Get('system.bindconf_directory')),
'<WEBSERVER_RELOAD_CMD>' => Settings::Get('system.apachereload_command'), '<WEBSERVER_RELOAD_CMD>' => Settings::Get('system.apachereload_command'),
'<CUSTOMER_LOGS>' => \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.logfiles_directory')), '<CUSTOMER_LOGS>' => makeCorrectDir(Settings::Get('system.logfiles_directory')),
'<FPM_IPCDIR>' => \Froxlor\FileDir::makeCorrectDir(Settings::Get('phpfpm.fastcgi_ipcdir')), '<FPM_IPCDIR>' => makeCorrectDir(Settings::Get('phpfpm.fastcgi_ipcdir')),
'<WEBSERVER_GROUP>' => Settings::Get('system.httpgroup') '<WEBSERVER_GROUP>' => Settings::Get('system.httpgroup')
); );
@@ -114,17 +79,17 @@ if ($userinfo['change_serversettings'] == '1') {
$services = ""; $services = "";
$daemons = ""; $daemons = "";
$config_dir = \Froxlor\FileDir::makeCorrectDir(\Froxlor\Froxlor::getInstallDir() . '/lib/configfiles/'); $config_dir = makeCorrectDir(FROXLOR_INSTALL_DIR . '/lib/configfiles/');
if ($distribution != "") { if ($distribution != "") {
if (!file_exists($config_dir . '/' . $distribution . ".xml")) { if (!file_exists($config_dir . '/' . $distribution . ".xml")) {
trigger_error("Unknown distribution, are you playing around with the URL?"); trigger_error("Unknown distribution, are you playing around with the URL?");
exit(); exit;
} }
// create configparser object // create configparser object
$configfiles = new \Froxlor\Config\ConfigParser($config_dir . '/' . $distribution . ".xml"); $configfiles = new ConfigParser($config_dir . '/' . $distribution . ".xml");
// get distro-info // get distro-info
$dist_display = getCompleteDistroName($configfiles); $dist_display = getCompleteDistroName($configfiles);
@@ -136,7 +101,7 @@ if ($userinfo['change_serversettings'] == '1') {
if (!isset($services[$service])) { if (!isset($services[$service])) {
trigger_error("Unknown service, are you playing around with the URL?"); trigger_error("Unknown service, are you playing around with the URL?");
exit(); exit;
} }
$daemons = $services[$service]->getDaemons(); $daemons = $services[$service]->getDaemons();
@@ -147,12 +112,12 @@ if ($userinfo['change_serversettings'] == '1') {
if ($dd->default) { if ($dd->default) {
$title = $title . " (" . strtolower($lng['panel']['default']) . ")"; $title = $title . " (" . strtolower($lng['panel']['default']) . ")";
} }
$daemons_select .= \Froxlor\UI\HTML::makeoption($title, $di); $daemons_select .= makeoption($title, $di);
} }
} }
} else { } else {
foreach ($services as $si => $sd) { foreach ($services as $si => $sd) {
$services_select .= \Froxlor\UI\HTML::makeoption($sd->title, $si); $services_select .= makeoption($sd->title, $si);
} }
} }
} else { } else {
@@ -164,7 +129,7 @@ if ($userinfo['change_serversettings'] == '1') {
// read in all the distros // read in all the distros
foreach ($distros as $_distribution) { foreach ($distros as $_distribution) {
// get configparser object // get configparser object
$dist = new \Froxlor\Config\ConfigParser($_distribution); $dist = new ConfigParser($_distribution);
// get distro-info // get distro-info
$dist_display = getCompleteDistroName($dist); $dist_display = getCompleteDistroName($dist);
// store in tmp array // store in tmp array
@@ -176,7 +141,7 @@ if ($userinfo['change_serversettings'] == '1') {
foreach ($distributions_select_data as $dist_display => $dist_index) { foreach ($distributions_select_data as $dist_display => $dist_index) {
// create select-box-option // create select-box-option
$distributions_select .= \Froxlor\UI\HTML::makeoption($dist_display, $dist_index); $distributions_select .= makeoption($dist_display, $dist_index);
} }
} }
@@ -184,7 +149,7 @@ if ($userinfo['change_serversettings'] == '1') {
if (!isset($daemons[$daemon])) { if (!isset($daemons[$daemon])) {
trigger_error("Unknown daemon, are you playing around with the URL?"); trigger_error("Unknown daemon, are you playing around with the URL?");
exit(); exit;
} }
$confarr = $daemons[$daemon]->getConfig(); $confarr = $daemons[$daemon]->getConfig();
@@ -199,49 +164,49 @@ if ($userinfo['change_serversettings'] == '1') {
$lasttype = ''; $lasttype = '';
$commands = ''; $commands = '';
foreach ($confarr as $_action) { foreach ($confarr as $idx => $action) {
if ($lasttype != '' && $lasttype != $_action['type']) { if ($lasttype != '' && $lasttype != $action['type']) {
$commands = trim($commands); $commands = trim($commands);
$numbrows = count(explode("\n", $commands)); $numbrows = count(explode("\n", $commands));
eval("\$configpage.=\"" . \Froxlor\UI\Template::getTemplate("configfiles/configfiles_commands") . "\";"); eval("\$configpage.=\"" . getTemplate("configfiles/configfiles_commands") . "\";");
$lasttype = ''; $lasttype = '';
$commands = ''; $commands = '';
} }
switch ($_action['type']) { switch ($action['type']) {
case "install": case "install":
$commands .= strtr($_action['content'], $replace_arr) . "\n"; $commands .= strtr($action['content'], $replace_arr) . "\n";
$lasttype = "install"; $lasttype = "install";
break; break;
case "command": case "command":
$commands .= strtr($_action['content'], $replace_arr) . "\n"; $commands .= strtr($action['content'], $replace_arr) . "\n";
$lasttype = "command"; $lasttype = "command";
break; break;
case "file": case "file":
if (array_key_exists('content', $_action)) { if (array_key_exists('content', $action)) {
$commands_file = getFileContentContainer($_action['content'], $replace_arr, $_action['name'], $distro_editor); $commands_file = getFileContentContainer($action['content'], $replace_arr, $action['name'], $distro_editor);
} elseif (array_key_exists('subcommands', $_action)) { } elseif (array_key_exists('subcommands', $action)) {
foreach ($_action['subcommands'] as $fileaction) { foreach ($action['subcommands'] as $fileaction) {
if (array_key_exists('execute', $fileaction) && $fileaction['execute'] == "pre") { if (array_key_exists('execute', $fileaction) && $fileaction['execute'] == "pre") {
$commands_pre .= $fileaction['content'] . "\n"; $commands_pre .= $fileaction['content'] . "\n";
} elseif (array_key_exists('execute', $fileaction) && $fileaction['execute'] == "post") { } elseif (array_key_exists('execute', $fileaction) && $fileaction['execute'] == "post") {
$commands_post .= $fileaction['content'] . "\n"; $commands_post .= $fileaction['content'] . "\n";
} elseif ($fileaction['type'] == 'file') { } elseif ($fileaction['type'] == 'file') {
$commands_file = getFileContentContainer($fileaction['content'], $replace_arr, $_action['name'], $distro_editor); $commands_file = getFileContentContainer($fileaction['content'], $replace_arr, $action['name'], $distro_editor);
} }
} }
} }
$realname = $_action['name']; $realname = $action['name'];
$commands = trim($commands_pre); $commands = trim($commands_pre);
if ($commands != "") { if ($commands != "") {
$numbrows = count(explode("\n", $commands)); $numbrows = count(explode("\n", $commands));
eval("\$commands_pre=\"" . \Froxlor\UI\Template::getTemplate("configfiles/configfiles_commands") . "\";"); eval("\$commands_pre=\"" . getTemplate("configfiles/configfiles_commands") . "\";");
} }
$commands = trim($commands_post); $commands = trim($commands_post);
if ($commands != "") { if ($commands != "") {
$numbrows = count(explode("\n", $commands)); $numbrows = count(explode("\n", $commands));
eval("\$commands_post=\"" . \Froxlor\UI\Template::getTemplate("configfiles/configfiles_commands") . "\";"); eval("\$commands_post=\"" . getTemplate("configfiles/configfiles_commands") . "\";");
} }
eval("\$configpage.=\"" . \Froxlor\UI\Template::getTemplate("configfiles/configfiles_subfileblock") . "\";"); eval("\$configpage.=\"" . getTemplate("configfiles/configfiles_subfileblock") . "\";");
$commands = ''; $commands = '';
$commands_pre = ''; $commands_pre = '';
$commands_post = ''; $commands_post = '';
@@ -251,17 +216,15 @@ if ($userinfo['change_serversettings'] == '1') {
$commands = trim($commands); $commands = trim($commands);
if ($commands != '') { if ($commands != '') {
$numbrows = count(explode("\n", $commands)); $numbrows = count(explode("\n", $commands));
eval("\$configpage.=\"" . \Froxlor\UI\Template::getTemplate("configfiles/configfiles_commands") . "\";"); eval("\$configpage.=\"" . getTemplate("configfiles/configfiles_commands") . "\";");
} }
eval("echo \"" . \Froxlor\UI\Template::getTemplate("configfiles/configfiles") . "\";"); eval("echo \"" . getTemplate("configfiles/configfiles") . "\";");
} else { } else {
$basedir = \Froxlor\Froxlor::getInstallDir(); eval("echo \"" . getTemplate("configfiles/wizard") . "\";");
eval("echo \"" . \Froxlor\UI\Template::getTemplate("configfiles/wizard") . "\";");
} }
} else { } else {
\Froxlor\UI\Response::redirectTo('admin_index.php', array( die('not allowed to see this page');
's' => $s // redirect or similar here
));
} }
// helper functions // helper functions
@@ -273,7 +236,7 @@ function getFileContentContainer($file_content, &$replace_arr, $realname, $distr
$file_content = strtr($file_content, $replace_arr); $file_content = strtr($file_content, $replace_arr);
$file_content = htmlspecialchars($file_content); $file_content = htmlspecialchars($file_content);
$numbrows = count(explode("\n", $file_content)); $numbrows = count(explode("\n", $file_content));
eval("\$files=\"" . \Froxlor\UI\Template::getTemplate("configfiles/configfiles_file") . "\";"); eval("\$files=\"" . getTemplate("configfiles/configfiles_file") . "\";");
} }
return $files; return $files;
} }

View File

@@ -14,11 +14,10 @@
* @package Panel * @package Panel
* *
*/ */
define('AREA', 'admin'); define('AREA', 'admin');
require './lib/init.php'; require './lib/init.php';
use Froxlor\Api\Commands\Cronjobs;
if (isset($_POST['id'])) { if (isset($_POST['id'])) {
$id = intval($_POST['id']); $id = intval($_POST['id']);
} elseif(isset($_GET['id'])) { } elseif(isset($_GET['id'])) {
@@ -27,77 +26,83 @@ if (isset($_POST['id'])) {
if ($page == 'cronjobs' || $page == 'overview') { if ($page == 'cronjobs' || $page == 'overview') {
if ($action == '') { if ($action == '') {
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'viewed admin_cronjobs'); $log->logAction(ADM_ACTION, LOG_NOTICE, 'viewed admin_cronjobs');
$fields = array( $fields = array(
'c.module' => 'Module',
'c.lastrun' => $lng['cron']['lastrun'], 'c.lastrun' => $lng['cron']['lastrun'],
'c.interval' => $lng['cron']['interval'], 'c.interval' => $lng['cron']['interval'],
'c.isactive' => $lng['cron']['isactive'] 'c.isactive' => $lng['cron']['isactive']
); );
try { $paging = new paging($userinfo, TABLE_PANEL_CRONRUNS, $fields);
// get total count
$json_result = Cronjobs::getLocal($userinfo)->listingCount();
$result = json_decode($json_result, true)['data'];
// initialize pagination and filtering
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
// get list
$json_result = Cronjobs::getLocal($userinfo, $paging->getApiCommandParams())->listing();
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$crons = ''; $crons = '';
$result_stmt = Database::prepare("SELECT `c`.* FROM `" . TABLE_PANEL_CRONRUNS . "` `c` ORDER BY `module` ASC, `cronfile` ASC");
Database::pexecute($result_stmt);
$paging->setEntries(Database::num_rows());
$sortcode = $paging->getHtmlSortCode($lng); $sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s); $arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng); $searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s); $pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$i = 0;
$count = 0; $count = 0;
$cmod = ''; $cmod = '';
foreach ($result['list'] as $row) { while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
if ($cmod != $row['module']) { if ($cmod != $row['module']) {
$_mod = explode("/", $row['module']); $_mod = explode("/", $row['module']);
$module = ucfirst($_mod[1]); $module = ucfirst($_mod[1]);
eval("\$crons.=\"" . \Froxlor\UI\Template::getTemplate('cronjobs/cronjobs_cronjobmodule') . "\";"); eval("\$crons.=\"" . getTemplate('cronjobs/cronjobs_cronjobmodule') . "\";");
$cmod = $row['module']; $cmod = $row['module'];
} }
$row = \Froxlor\PhpHelper::htmlentitiesArray($row); if ($paging->checkDisplay($i)) {
$row = htmlentities_array($row);
$row['lastrun'] = date('d.m.Y H:i', $row['lastrun']); $row['lastrun'] = date('d.m.Y H:i', $row['lastrun']);
$row['isactive'] = ((int)$row['isactive'] == 1) ? $lng['panel']['yes'] : $lng['panel']['no']; $row['isactive'] = ((int)$row['isactive'] == 1) ? $lng['panel']['yes'] : $lng['panel']['no'];
$description = $lng['crondesc'][$row['desc_lng_key']]; $description = $lng['crondesc'][$row['desc_lng_key']];
eval("\$crons.=\"" . \Froxlor\UI\Template::getTemplate('cronjobs/cronjobs_cronjob') . "\";"); eval("\$crons.=\"" . getTemplate('cronjobs/cronjobs_cronjob') . "\";");
$count++; $count++;
} }
eval("echo \"" . \Froxlor\UI\Template::getTemplate('cronjobs/cronjobs') . "\";"); $i++;
}
eval("echo \"" . getTemplate('cronjobs/cronjobs') . "\";");
} elseif ($action == 'new') { } elseif ($action == 'new') {
/* /*
* @TODO later * @TODO later
*/ */
} elseif ($action == 'edit' && $id != 0) { } elseif ($action == 'edit' && $id != 0) {
try { $result_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_CRONRUNS . "` WHERE `id`= :id");
$json_result = Cronjobs::getLocal($userinfo, array( Database::pexecute($result_stmt, array('id' => $id));
'id' => $id $result = $result_stmt->fetch(PDO::FETCH_ASSOC);
))->get();
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
if ($result['cronfile'] != '') { if ($result['cronfile'] != '') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { $isactive = isset($_POST['isactive']) ? 1 : 0;
Cronjobs::getLocal($userinfo, $_POST)->update(); $interval_value = validate($_POST['interval_value'], 'interval_value', '/^([0-9]+)$/Di', 'stringisempty');
} catch (Exception $e) { $interval_interval = validate($_POST['interval_interval'], 'interval_interval');
\Froxlor\UI\Response::dynamic_error($e->getMessage());
if ($isactive != 1) {
$isactive = 0;
} }
\Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page, $interval = $interval_value . ' ' . strtoupper($interval_interval);
's' => $s
)); $upd = Database::prepare("
UPDATE `" . TABLE_PANEL_CRONRUNS . "`
SET `isactive` = :isactive, `interval` = :int
WHERE `id` = :id"
);
Database::pexecute($upd, array('isactive' => $isactive, 'int' => $interval, 'id' => $id));
// insert task to re-generate the cron.d-file
inserttask('99');
redirectTo($filename, array('page' => $page, 's' => $s));
} else { } else {
// interval // interval
@@ -105,11 +110,11 @@ if ($page == 'cronjobs' || $page == 'overview') {
$interval_value = $interval_nfo[0]; $interval_value = $interval_nfo[0];
$interval_interval = ''; $interval_interval = '';
$interval_interval .= \Froxlor\UI\HTML::makeoption($lng['cronmgmt']['minutes'], 'MINUTE', $interval_nfo[1]); $interval_interval .= makeoption($lng['cronmgmt']['minutes'], 'MINUTE', $interval_nfo[1]);
$interval_interval .= \Froxlor\UI\HTML::makeoption($lng['cronmgmt']['hours'], 'HOUR', $interval_nfo[1]); $interval_interval .= makeoption($lng['cronmgmt']['hours'], 'HOUR', $interval_nfo[1]);
$interval_interval .= \Froxlor\UI\HTML::makeoption($lng['cronmgmt']['days'], 'DAY', $interval_nfo[1]); $interval_interval .= makeoption($lng['cronmgmt']['days'], 'DAY', $interval_nfo[1]);
$interval_interval .= \Froxlor\UI\HTML::makeoption($lng['cronmgmt']['weeks'], 'WEEK', $interval_nfo[1]); $interval_interval .= makeoption($lng['cronmgmt']['weeks'], 'WEEK', $interval_nfo[1]);
$interval_interval .= \Froxlor\UI\HTML::makeoption($lng['cronmgmt']['months'], 'MONTH', $interval_nfo[1]); $interval_interval .= makeoption($lng['cronmgmt']['months'], 'MONTH', $interval_nfo[1]);
// end of interval // end of interval
$change_cronfile = false; $change_cronfile = false;
@@ -118,15 +123,16 @@ if ($page == 'cronjobs' || $page == 'overview') {
} }
$cronjobs_edit_data = include_once dirname(__FILE__).'/lib/formfields/admin/cronjobs/formfield.cronjobs_edit.php'; $cronjobs_edit_data = include_once dirname(__FILE__).'/lib/formfields/admin/cronjobs/formfield.cronjobs_edit.php';
$cronjobs_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($cronjobs_edit_data); $cronjobs_edit_form = htmlform::genHTMLForm($cronjobs_edit_data);
$title = $cronjobs_edit_data['cronjobs_edit']['title']; $title = $cronjobs_edit_data['cronjobs_edit']['title'];
$image = $cronjobs_edit_data['cronjobs_edit']['image']; $image = $cronjobs_edit_data['cronjobs_edit']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate('cronjobs/cronjob_edit') . "\";"); eval("echo \"" . getTemplate('cronjobs/cronjob_edit') . "\";");
} }
} }
} elseif ($action == 'delete' && $id != 0) { }
elseif ($action == 'delete' && $id != 0) {
/* /*
* @TODO later * @TODO later
*/ */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -16,36 +16,32 @@
* @package Panel * @package Panel
* *
*/ */
define('AREA', 'admin'); define('AREA', 'admin');
require './lib/init.php'; require './lib/init.php';
use Froxlor\Database\Database;
use Froxlor\Settings;
use Froxlor\Api\Commands\Froxlor as Froxlor;
use Froxlor\Api\Commands\Admins as Admins;
if ($action == 'logout') { if ($action == 'logout') {
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "logged out"); $log->logAction(ADM_ACTION, LOG_NOTICE, "logged out");
$params = array( $params = array('adminid' => (int)$userinfo['adminid']);
'adminid' => (int) $userinfo['adminid']
);
if (Settings::Get('session.allow_multiple_login') == '1') { if (Settings::Get('session.allow_multiple_login') == '1') {
$stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_SESSIONS . "` $stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_SESSIONS . "`
WHERE `userid` = :adminid WHERE `userid` = :adminid
AND `adminsession` = '1' AND `adminsession` = '1'
AND `hash` = :hash"); AND `hash` = :hash"
);
$params['hash'] = $s; $params['hash'] = $s;
} else { } else {
$stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_SESSIONS . "` $stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_SESSIONS . "`
WHERE `userid` = :adminid WHERE `userid` = :adminid
AND `adminsession` = '1'"); AND `adminsession` = '1'"
);
} }
Database::pexecute($stmt, $params); Database::pexecute($stmt, $params);
\Froxlor\UI\Response::redirectTo('index.php'); redirectTo('index.php');
} }
if (isset($_POST['id'])) { if (isset($_POST['id'])) {
@@ -55,14 +51,7 @@ if (isset($_POST['id'])) {
} }
if ($page == 'overview') { if ($page == 'overview') {
$log->logAction(ADM_ACTION, LOG_NOTICE, "viewed admin_index");
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_index");
$params = [];
if ($userinfo['customers_see_all'] == '0') {
$params = [
'adminid' => $userinfo['adminid']
];
}
$overview_stmt = Database::prepare("SELECT COUNT(*) AS `number_customers`, $overview_stmt = Database::prepare("SELECT COUNT(*) AS `number_customers`,
SUM(`diskspace_used`) AS `diskspace_used`, SUM(`diskspace_used`) AS `diskspace_used`,
SUM(`mysqls_used`) AS `mysqls_used`, SUM(`mysqls_used`) AS `mysqls_used`,
@@ -71,21 +60,21 @@ if ($page == 'overview') {
SUM(`email_forwarders_used`) AS `email_forwarders_used`, SUM(`email_forwarders_used`) AS `email_forwarders_used`,
SUM(`email_quota_used`) AS `email_quota_used`, SUM(`email_quota_used`) AS `email_quota_used`,
SUM(`ftps_used`) AS `ftps_used`, SUM(`ftps_used`) AS `ftps_used`,
SUM(`tickets_used`) AS `tickets_used`,
SUM(`subdomains_used`) AS `subdomains_used`, SUM(`subdomains_used`) AS `subdomains_used`,
SUM(`traffic_used`) AS `traffic_used` SUM(`traffic_used`) AS `traffic_used`
FROM `" . TABLE_PANEL_CUSTOMERS . "`" . ($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = :adminid ")); FROM `" . TABLE_PANEL_CUSTOMERS . "`" . ($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = :adminid "));
$overview = Database::pexecute_first($overview_stmt, $params); $overview = Database::pexecute_first($overview_stmt, array('adminid' => $userinfo['adminid']));
$dec_places = Settings::Get('panel.decimal_places'); $dec_places = Settings::Get('panel.decimal_places');
$overview['traffic_bytes_used'] = $overview['traffic_used'] * 1024; $overview['traffic_used'] = round($overview['traffic_used'] / (1024 * 1024), $dec_places);
$overview['traffic_used'] = \Froxlor\PhpHelper::sizeReadable($overview['traffic_used'] * 1024, null, 'bi'); $overview['diskspace_used'] = round($overview['diskspace_used'] / 1024, $dec_places);
$overview['diskspace_bytes_used'] = $overview['diskspace_used'] * 1024;
$overview['diskspace_used'] = \Froxlor\PhpHelper::sizeReadable($overview['diskspace_used'] * 1024, null, 'bi');
$number_domains_stmt = Database::prepare(" $number_domains_stmt = Database::prepare("
SELECT COUNT(*) AS `number_domains` FROM `" . TABLE_PANEL_DOMAINS . "` SELECT COUNT(*) AS `number_domains` FROM `" . TABLE_PANEL_DOMAINS . "`
WHERE `parentdomainid`='0'" . ($userinfo['customers_see_all'] ? '' : " AND `adminid` = :adminid")); WHERE `parentdomainid`='0'" . ($userinfo['customers_see_all'] ? '' : " AND `adminid` = :adminid")
$number_domains = Database::pexecute_first($number_domains_stmt, $params); );
$number_domains = Database::pexecute_first($number_domains_stmt, array('adminid' => $userinfo['adminid']));
$overview['number_domains'] = $number_domains['number_domains']; $overview['number_domains'] = $number_domains['number_domains'];
@@ -93,44 +82,64 @@ if ($page == 'overview') {
$mysqlserverversion = Database::getAttribute(PDO::ATTR_SERVER_VERSION); $mysqlserverversion = Database::getAttribute(PDO::ATTR_SERVER_VERSION);
$webserverinterface = strtoupper(@php_sapi_name()); $webserverinterface = strtoupper(@php_sapi_name());
if ((isset($_GET['lookfornewversion']) && $_GET['lookfornewversion'] == 'yes') || (isset($lookfornewversion) && $lookfornewversion == 'yes')) { if ((isset($_GET['lookfornewversion']) && $_GET['lookfornewversion'] == 'yes')
try { || (isset($lookfornewversion) && $lookfornewversion == 'yes')
$json_result = Froxlor::getLocal($userinfo)->checkUpdate(); ) {
} catch (Exception $e) { if (function_exists('curl_version')) {
\Froxlor\UI\Response::dynamic_error($e->getMessage()); $update_check_uri = 'http://version.froxlor.org/Froxlor/legacy/' . $version;
} $latestversion = HttpClient::urlGet($update_check_uri);
$result = json_decode($json_result, true)['data']; $latestversion = explode('|', $latestversion);
$lookfornewversion_lable = $result['version']; if (is_array($latestversion)
$lookfornewversion_link = $result['link']; && count($latestversion) >= 1
$lookfornewversion_message = $result['message']; ) {
$lookfornewversion_addinfo = $result['additional_info']; $_version = $latestversion[0];
$isnewerversion = $result['isnewerversion']; $_message = isset($latestversion[1]) ? $latestversion[1] : '';
$_link = isset($latestversion[2]) ? $latestversion[2] : htmlspecialchars($filename . '?s=' . urlencode($s) . '&page=' . urlencode($page) . '&lookfornewversion=yes');
// add the branding so debian guys are not gettings confused
// about their version-number
$lookfornewversion_lable = $_version.$branding;
$lookfornewversion_link = $_link;
$lookfornewversion_addinfo = $_message;
// not numeric -> error-message
if (!preg_match('/^((\d+\\.)(\d+\\.)(\d+\\.)?(\d+)?(\-(svn|dev|rc)(\d+))?)$/', $_version)) {
// check for customized version to not output
// "There is a newer version of froxlor" besides the error-message
$isnewerversion = 2;
} elseif (version_compare2($version, $_version) == -1) {
$isnewerversion = 1;
} else {
$isnewerversion = 0;
}
} else {
redirectTo($update_check_uri.'/pretty', NULL, false);
}
} else {
$lookfornewversion_lable = "Version-check not available due to missing php-curl extension";
$lookfornewversion_link = htmlspecialchars($filename . '?s=' . urlencode($s) . '&page=' . urlencode($page) . '&lookfornewversion=yes');
$lookfornewversion_addinfo = '';
$isnewerversion = 0;
}
} else { } 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 . '?s=' . urlencode($s) . '&page=' . urlencode($page) . '&lookfornewversion=yes');
$lookfornewversion_message = '';
$lookfornewversion_addinfo = ''; $lookfornewversion_addinfo = '';
$isnewerversion = 0; $isnewerversion = 0;
} }
$dec_places = Settings::Get('panel.decimal_places'); $dec_places = Settings::Get('panel.decimal_places');
// get everything in bytes for the percentage calculation on the dashboard $userinfo['diskspace'] = round($userinfo['diskspace'] / 1024, $dec_places);
$userinfo['diskspace_bytes'] = ($userinfo['diskspace'] > -1) ? $userinfo['diskspace'] * 1024 : -1; $userinfo['diskspace_used'] = round($userinfo['diskspace_used'] / 1024, $dec_places);
$userinfo['diskspace_bytes_used'] = $userinfo['diskspace_used'] * 1024; $userinfo['traffic'] = round($userinfo['traffic'] / (1024 * 1024), $dec_places);
$userinfo['traffic_bytes'] = ($userinfo['traffic'] > -1) ? $userinfo['traffic'] * 1024 : - 1; $userinfo['traffic_used'] = round($userinfo['traffic_used'] / (1024 * 1024), $dec_places);
$userinfo['traffic_bytes_used'] = $userinfo['traffic_used'] * 1024; $userinfo = str_replace_array('-1', $lng['customer']['unlimited'], $userinfo, 'customers domains diskspace traffic mysqls emails email_accounts email_forwarders email_quota ftps tickets subdomains');
$userinfo['diskspace'] = ($userinfo['diskspace'] > -1) ? \Froxlor\PhpHelper::sizeReadable($userinfo['diskspace'] * 1024, null, 'bi') : - 1;
$userinfo['diskspace_used'] = \Froxlor\PhpHelper::sizeReadable($userinfo['diskspace_used'] * 1024, null, 'bi');
$userinfo['traffic'] = ($userinfo['traffic'] > -1) ? \Froxlor\PhpHelper::sizeReadable($userinfo['traffic'] * 1024, null, 'bi') : - 1;
$userinfo['traffic_used'] = \Froxlor\PhpHelper::sizeReadable($userinfo['traffic_used'] * 1024, null, 'bi');
$userinfo = \Froxlor\PhpHelper::strReplaceArray('-1', $lng['customer']['unlimited'], $userinfo, 'customers domains diskspace diskspace_bytes traffic traffic_bytes mysqls emails email_accounts email_forwarders email_quota ftps subdomains');
$userinfo['custom_notes'] = ($userinfo['custom_notes'] != '') ? nl2br($userinfo['custom_notes']) : ''; $userinfo['custom_notes'] = ($userinfo['custom_notes'] != '') ? nl2br($userinfo['custom_notes']) : '';
$cron_last_runs = \Froxlor\System\Cronjob::getCronjobsLastRun(); $cron_last_runs = getCronjobsLastRun();
$outstanding_tasks = \Froxlor\System\Cronjob::getOutstandingTasks(); $outstanding_tasks = getOutstandingTasks();
$system_hostname = gethostname(); $system_hostname = gethostname();
$meminfo= explode("\n", @file_get_contents("/proc/meminfo")); $meminfo= explode("\n", @file_get_contents("/proc/meminfo"));
@@ -165,7 +174,10 @@ if ($page == 'overview') {
// First: With exec (let's hope it's enabled for the Froxlor - vHost) // First: With exec (let's hope it's enabled for the Froxlor - vHost)
$uptime_array = explode(" ", @file_get_contents("/proc/uptime")); $uptime_array = explode(" ", @file_get_contents("/proc/uptime"));
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;
@@ -183,86 +195,79 @@ if ($page == 'overview') {
$uptime = ''; $uptime = '';
} }
eval("echo \"" . \Froxlor\UI\Template::getTemplate("index/index") . "\";"); eval("echo \"" . getTemplate("index/index") . "\";");
} elseif($page == 'change_password') { } elseif($page == 'change_password') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send'])
$old_password = \Froxlor\Validate\Validate::validate($_POST['old_password'], 'old password'); && $_POST['send'] == 'send'
) {
$old_password = validate($_POST['old_password'], 'old password');
if (! \Froxlor\System\Crypt::validatePasswordLogin($userinfo, $old_password, TABLE_PANEL_ADMINS, 'adminid')) { if (!validatePasswordLogin($userinfo,$old_password,TABLE_PANEL_ADMINS,'adminid')) {
\Froxlor\UI\Response::standard_error('oldpasswordnotcorrect'); standard_error('oldpasswordnotcorrect');
} }
try { $new_password = validate($_POST['new_password'], 'new password');
$new_password = \Froxlor\System\Crypt::validatePassword($_POST['new_password'], 'new password'); $new_password_confirm = validate($_POST['new_password_confirm'], 'new password confirm');
$new_password_confirm = \Froxlor\System\Crypt::validatePassword($_POST['new_password_confirm'], 'new password confirm');
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
if ($old_password == '') { if ($old_password == '') {
\Froxlor\UI\Response::standard_error(array( standard_error(array('stringisempty', 'oldpassword'));
'stringisempty',
'oldpassword'
));
} elseif($new_password == '') { } elseif($new_password == '') {
\Froxlor\UI\Response::standard_error(array( standard_error(array('stringisempty', 'newpassword'));
'stringisempty',
'newpassword'
));
} elseif($new_password_confirm == '') { } elseif($new_password_confirm == '') {
\Froxlor\UI\Response::standard_error(array( standard_error(array('stringisempty', 'newpasswordconfirm'));
'stringisempty',
'newpasswordconfirm'
));
} elseif($new_password != $new_password_confirm) { } elseif($new_password != $new_password_confirm) {
\Froxlor\UI\Response::standard_error('newpasswordconfirmerror'); standard_error('newpasswordconfirmerror');
} else { } else {
try { $chgpwd_stmt = Database::prepare("
Admins::getLocal($userinfo, array( UPDATE `" . TABLE_PANEL_ADMINS . "`
'id' => $userinfo['adminid'], SET `password`= :newpasswd
'admin_password' => $new_password WHERE `adminid`= :adminid"
))->update(); );
} catch (Exception $e) { Database::pexecute($chgpwd_stmt, array(
\Froxlor\UI\Response::dynamic_error($e->getMessage()); 'newpasswd' => makeCryptPassword($new_password),
} 'adminid' => (int)$userinfo['adminid']
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'changed password');
\Froxlor\UI\Response::redirectTo($filename, Array(
's' => $s
)); ));
$log->logAction(ADM_ACTION, LOG_NOTICE, 'changed password');
redirectTo($filename, Array('s' => $s));
} }
} else { } else {
eval("echo \"" . \Froxlor\UI\Template::getTemplate("index/change_password") . "\";"); eval("echo \"" . getTemplate("index/change_password") . "\";");
} }
} elseif($page == 'change_language') { } elseif($page == 'change_language') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send'])
$def_language = \Froxlor\Validate\Validate::validate($_POST['def_language'], 'default language'); && $_POST['send'] == 'send'
) {
$def_language = validate($_POST['def_language'], 'default language');
if (isset($languages[$def_language])) { if (isset($languages[$def_language])) {
try { $lng_stmt = Database::prepare("
Admins::getLocal($userinfo, array( UPDATE `" . TABLE_PANEL_ADMINS . "`
'id' => $userinfo['adminid'], SET `def_language`= :deflng
'def_language' => $def_language WHERE `adminid`= :adminid"
))->update(); );
} catch (Exception $e) { Database::pexecute($lng_stmt, array(
\Froxlor\UI\Response::dynamic_error($e->getMessage()); 'deflng' => $def_language,
} 'adminid' => (int)$userinfo['adminid']
));
// also update current session
$lng_stmt = Database::prepare(" $lng_stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_SESSIONS . "` UPDATE `" . TABLE_PANEL_SESSIONS . "`
SET `language`= :lng SET `language`= :lng
WHERE `hash`= :hash"); WHERE `hash`= :hash"
);
Database::pexecute($lng_stmt, array( Database::pexecute($lng_stmt, array(
'lng' => $def_language, 'lng' => $def_language,
'hash' => $s 'hash' => $s
)); ));
} }
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "changed his/her default language to '" . $def_language . "'");
\Froxlor\UI\Response::redirectTo($filename, array( $log->logAction(ADM_ACTION, LOG_NOTICE, "changed his/her default language to '" . $def_language . "'");
's' => $s redirectTo($filename, array('s' => $s));
));
} else { } else {
$language_options = ''; $language_options = '';
@@ -273,38 +278,42 @@ if ($page == 'overview') {
} }
foreach ($languages as $language_file => $language_name) { foreach ($languages as $language_file => $language_name) {
$language_options .= \Froxlor\UI\HTML::makeoption($language_name, $language_file, $default_lang, true); $language_options.= makeoption($language_name, $language_file, $default_lang, true);
} }
eval("echo \"" . \Froxlor\UI\Template::getTemplate("index/change_language") . "\";"); eval("echo \"" . getTemplate("index/change_language") . "\";");
} }
} elseif ($page == 'change_theme') { } elseif ($page == 'change_theme') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send'])
$theme = \Froxlor\Validate\Validate::validate($_POST['theme'], 'theme'); && $_POST['send'] == 'send'
try { ) {
Admins::getLocal($userinfo, array( $theme = validate($_POST['theme'], 'theme');
'id' => $userinfo['adminid'],
'theme' => $theme $theme_stmt = Database::prepare("
))->update(); UPDATE `" . TABLE_PANEL_ADMINS . "`
} catch (Exception $e) { SET `theme`= :theme
\Froxlor\UI\Response::dynamic_error($e->getMessage()); WHERE `adminid`= :adminid"
} );
Database::pexecute($theme_stmt, array(
'theme' => $theme,
'adminid' => (int)$userinfo['adminid']
));
// also update current session
$theme_stmt = Database::prepare(" $theme_stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_SESSIONS . "` UPDATE `" . TABLE_PANEL_SESSIONS . "`
SET `theme`= :theme SET `theme`= :theme
WHERE `hash`= :hash"); WHERE `hash`= :hash"
);
Database::pexecute($theme_stmt, array( Database::pexecute($theme_stmt, array(
'theme' => $theme, 'theme' => $theme,
'hash' => $s 'hash' => $s
)); ));
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "changed his/her theme to '" . $theme . "'"); $log->logAction(ADM_ACTION, LOG_NOTICE, "changed his/her theme to '" . $theme . "'");
\Froxlor\UI\Response::redirectTo($filename, array( redirectTo($filename, array('s' => $s));
's' => $s
));
} else { } else {
$theme_options = ''; $theme_options = '';
@@ -314,22 +323,27 @@ if ($page == 'overview') {
$default_theme = $userinfo['theme']; $default_theme = $userinfo['theme'];
} }
$themes_avail = \Froxlor\UI\Template::getThemes(); $themes_avail = getThemes();
foreach ($themes_avail as $t => $d) { foreach ($themes_avail as $t => $d) {
$theme_options .= \Froxlor\UI\HTML::makeoption($d, $t, $default_theme, true); $theme_options.= makeoption($d, $t, $default_theme, true);
} }
eval("echo \"" . \Froxlor\UI\Template::getTemplate("index/change_theme") . "\";"); eval("echo \"" . getTemplate("index/change_theme") . "\";");
} }
} elseif ($page == 'send_error_report' && Settings::Get('system.allow_error_report_admin') == '1') {
} elseif ($page == 'send_error_report'
&& Settings::Get('system.allow_error_report_admin') == '1'
) {
// only show this if we really have an exception to report // only show this if we really have an exception to report
if (isset($_GET['errorid']) && $_GET['errorid'] != '') { if (isset($_GET['errorid'])
&& $_GET['errorid'] != ''
) {
$errid = $_GET['errorid']; $errid = $_GET['errorid'];
// read error file // read error file
$err_dir = \Froxlor\FileDir::makeCorrectDir(\Froxlor\Froxlor::getInstallDir() . "/logs/"); $err_dir = makeCorrectDir(FROXLOR_INSTALL_DIR."/logs/");
$err_file = \Froxlor\FileDir::makeCorrectFile($err_dir . "/" . $errid . "_sql-error.log"); $err_file = makeCorrectFile($err_dir."/".$errid."_sql-error.log");
if (file_exists($err_file)) { if (file_exists($err_file)) {
@@ -339,9 +353,9 @@ if ($page == 'overview') {
$_error = array( $_error = array(
'code' => str_replace("\n", "", substr($error[1], 5)), 'code' => str_replace("\n", "", substr($error[1], 5)),
'message' => str_replace("\n", "", substr($error[2], 4)), 'message' => str_replace("\n", "", substr($error[2], 4)),
'file' => str_replace("\n", "", substr($error[3], 5 + strlen(\Froxlor\Froxlor::getInstallDir()))), 'file' => str_replace("\n", "", substr($error[3], 5 + strlen(FROXLOR_INSTALL_DIR))),
'line' => str_replace("\n", "", substr($error[4], 5)), 'line' => str_replace("\n", "", substr($error[4], 5)),
'trace' => str_replace(\Froxlor\Froxlor::getInstallDir(), "", substr($error[5], 6)) 'trace' => str_replace(FROXLOR_INSTALL_DIR, "", substr($error[5], 6))
); );
// build mail-content // build mail-content
@@ -358,7 +372,9 @@ if ($page == 'overview') {
$mail_html = nl2br($mail_body); $mail_html = nl2br($mail_body);
// send actual report to dev-team // send actual report to dev-team
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send'])
&& $_POST['send'] == 'send'
) {
// send mail and say thanks // send mail and say thanks
$_mailerror = false; $_mailerror = false;
try { try {
@@ -367,7 +383,7 @@ if ($page == 'overview') {
$mail->MsgHTML($mail_html); $mail->MsgHTML($mail_html);
$mail->AddAddress('error-reports@froxlor.org', 'Froxlor Developer Team'); $mail->AddAddress('error-reports@froxlor.org', 'Froxlor Developer Team');
$mail->Send(); $mail->Send();
} catch (\PHPMailer\PHPMailer\Exception $e) { } catch(phpmailerException $e) {
$mailerr_msg = $e->errorMessage(); $mailerr_msg = $e->errorMessage();
$_mailerror = true; $_mailerror = true;
} catch (Exception $e) { } catch (Exception $e) {
@@ -377,30 +393,21 @@ if ($page == 'overview') {
if ($_mailerror) { if ($_mailerror) {
// error when reporting an error...LOLFUQ // error when reporting an error...LOLFUQ
\Froxlor\UI\Response::standard_error('send_report_error', $mailerr_msg); standard_error('send_report_error', $mailerr_msg);
} }
// finally remove error from fs // finally remove error from fs
@unlink($err_file); @unlink($err_file);
\Froxlor\UI\Response::redirectTo($filename, array( redirectTo($filename, array('s' => $s));
's' => $s
));
} }
// show a nice summary of the error-report // show a nice summary of the error-report
// before actually sending anything // before actually sending anything
eval("echo \"" . \Froxlor\UI\Template::getTemplate("index/send_error_report") . "\";"); eval("echo \"" . getTemplate("index/send_error_report") . "\";");
} else { } else {
\Froxlor\UI\Response::redirectTo($filename, array( redirectTo($filename, array('s' => $s));
's' => $s
));
} }
} else { } else {
\Froxlor\UI\Response::redirectTo($filename, array( redirectTo($filename, array('s' => $s));
's' => $s
));
} }
} 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';
} }

View File

@@ -16,19 +16,19 @@
* @package Panel * @package Panel
* *
*/ */
define('AREA', 'admin'); define('AREA', 'admin');
require './lib/init.php'; require './lib/init.php';
use Froxlor\Settings;
use Froxlor\Api\Commands\IpsAndPorts;
if (isset($_POST['id'])) { if (isset($_POST['id'])) {
$id = intval($_POST['id']); $id = intval($_POST['id']);
} elseif(isset($_GET['id'])) { } elseif(isset($_GET['id'])) {
$id = intval($_GET['id']); $id = intval($_GET['id']);
} }
if ($page == 'ipsandports' || $page == 'overview') { if ($page == 'ipsandports'
|| $page == 'overview'
) {
// Do not display attributes that are not used by the current webserver // Do not display attributes that are not used by the current webserver
$websrv = Settings::Get('system.webserver'); $websrv = Settings::Get('system.webserver');
$is_nginx = ($websrv == 'nginx'); $is_nginx = ($websrv == 'nginx');
@@ -37,137 +37,402 @@ if ($page == 'ipsandports' || $page == 'overview') {
if ($action == '') { if ($action == '') {
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_ipsandports"); $log->logAction(ADM_ACTION, LOG_NOTICE, "viewed admin_ipsandports");
$fields = array( $fields = array(
'ip' => $lng['admin']['ipsandports']['ip'], 'ip' => $lng['admin']['ipsandports']['ip'],
'port' => $lng['admin']['ipsandports']['port'] 'port' => $lng['admin']['ipsandports']['port']
); );
try { $paging = new paging($userinfo, TABLE_PANEL_IPSANDPORTS, $fields);
// get total count
$json_result = IpsAndPorts::getLocal($userinfo)->listingCount();
$result = json_decode($json_result, true)['data'];
// initialize pagination and filtering
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
// get list
$json_result = IpsAndPorts::getLocal($userinfo, $paging->getApiCommandParams())->listing();
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$ipsandports = ''; $ipsandports = '';
$result_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_IPSANDPORTS . "` " . $paging->getSqlWhere(false) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
Database::pexecute($result_stmt);
$paging->setEntries(Database::num_rows());
$sortcode = $paging->getHtmlSortCode($lng); $sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s); $arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng); $searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s); $pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$i = 0;
$count = 0; $count = 0;
foreach ($result['list'] as $row) { while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
if ($paging->checkDisplay($i)) {
$row = htmlentities_array($row);
if (filter_var($row['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { if (filter_var($row['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
$row['ip'] = '[' . $row['ip'] . ']'; $row['ip'] = '[' . $row['ip'] . ']';
} }
eval("\$ipsandports.=\"" . \Froxlor\UI\Template::getTemplate("ipsandports/ipsandports_ipandport") . "\";"); eval("\$ipsandports.=\"" . getTemplate("ipsandports/ipsandports_ipandport") . "\";");
$count++; $count++;
} }
eval("echo \"" . \Froxlor\UI\Template::getTemplate("ipsandports/ipsandports") . "\";"); $i++;
} elseif ($action == 'delete' && $id != 0) {
try {
$json_result = IpsAndPorts::getLocal($userinfo, array(
'id' => $id
))->get();
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
if (isset($result['id']) && $result['id'] == $id) {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
try {
IpsAndPorts::getLocal($userinfo, array(
'id' => $id
))->delete();
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
\Froxlor\UI\Response::redirectTo($filename, array( eval("echo \"" . getTemplate("ipsandports/ipsandports") . "\";");
'page' => $page,
's' => $s } elseif($action == 'delete'
)); && $id != 0
) {
$result_stmt = Database::prepare("SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = :id");
$result = Database::pexecute_first($result_stmt, array('id' => $id));
if (isset($result['id'])
&& $result['id'] == $id
) {
$result_checkdomain_stmt = Database::prepare("
SELECT `id_domain` as `id` FROM `" . TABLE_DOMAINTOIP . "` WHERE `id_ipandports` = :id"
);
$result_checkdomain = Database::pexecute_first($result_checkdomain_stmt, array('id' => $id));
if ($result_checkdomain['id'] == '') {
if (!in_array($result['id'], explode(',', Settings::Get('system.defaultip')))) {
$result_sameipotherport_stmt = Database::prepare("
SELECT `id` FROM `" . TABLE_PANEL_IPSANDPORTS . "`
WHERE `ip` = :ip AND `id` <> :id"
);
$result_sameipotherport = Database::pexecute_first($result_sameipotherport_stmt, array('id' => $id, 'ip' => $result['ip']));
if (($result['ip'] != Settings::Get('system.ipaddress'))
|| ($result['ip'] == Settings::Get('system.ipaddress')
&& $result_sameipotherport['id'] != '')
) {
$result_stmt = Database::prepare("
SELECT `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "`
WHERE `id` = :id"
);
$result = Database::pexecute_first($result_stmt, array('id' => $id));
if ($result['ip'] != '') {
if (isset($_POST['send'])
&& $_POST['send'] == 'send'
) {
$del_stmt = Database::prepare("
DELETE FROM `" . TABLE_PANEL_IPSANDPORTS . "`
WHERE `id` = :id"
);
Database::pexecute($del_stmt, array('id' => $id));
// also, remove connections to domains (multi-stack)
$del_stmt = Database::prepare("
DELETE FROM `".TABLE_DOMAINTOIP."` WHERE `id_ipandports` = :id"
);
Database::pexecute($del_stmt, array('id' => $id));
$log->logAction(ADM_ACTION, LOG_WARNING, "deleted IP/port '" . $result['ip'] . ":" . $result['port'] . "'");
inserttask('1');
// Using nameserver, insert a task which rebuilds the server config
inserttask('4');
redirectTo($filename, array('page' => $page, 's' => $s));
} else { } else {
\Froxlor\UI\HTML::askYesNo('admin_ip_reallydelete', $filename, array( ask_yesno('admin_ip_reallydelete', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $result['ip'] . ':' . $result['port']);
'id' => $id,
'page' => $page,
'action' => $action
), $result['ip'] . ':' . $result['port']);
} }
} }
} else {
standard_error('cantdeletesystemip');
}
} else {
standard_error('cantdeletedefaultip');
}
} else {
standard_error('ipstillhasdomains');
}
}
} elseif($action == 'add') { } elseif($action == 'add') {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { if (isset($_POST['send'])
IpsAndPorts::getLocal($userinfo, $_POST)->add(); && $_POST['send'] == 'send'
} catch (Exception $e) { ) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
$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 = isset($_POST['listen_statement']) ? 1 : 0;
$namevirtualhost_statement = isset($_POST['namevirtualhost_statement']) ? 1 : 0;
$vhostcontainer = isset($_POST['vhostcontainer']) ? 1 : 0;
$specialsettings = validate(str_replace("\r\n", "\n", $_POST['specialsettings']), 'specialsettings', '/^[^\0]*$/');
$vhostcontainer_servername_statement = isset($_POST['vhostcontainer_servername_statement']) ? 1 : 0;
$default_vhostconf_domain = validate(str_replace("\r\n", "\n", $_POST['default_vhostconf_domain']), 'default_vhostconf_domain', '/^[^\0]*$/');
$docroot = validate($_POST['docroot'], 'docroot');
if ((int)Settings::Get('system.use_ssl') == 1) {
$ssl = isset($_POST['ssl']) ? intval($_POST['ssl']) : 0;
$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');
$ssl_cert_chainfile = validate($_POST['ssl_cert_chainfile'], 'ssl_cert_chainfile');
} else {
$ssl = 0;
$ssl_cert_file = '';
$ssl_key_file = '';
$ssl_ca_file = '';
$ssl_cert_chainfile = '';
} }
\Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page, if ($listen_statement != '1') {
's' => $s $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 ($ssl_cert_chainfile != '') {
$ssl_cert_chainfile = makeCorrectFile($ssl_cert_chainfile);
}
if (strlen(trim($docroot)) > 0) {
$docroot = makeCorrectDir($docroot);
} else {
$docroot = '';
}
$result_checkfordouble_stmt = Database::prepare("
SELECT `id` FROM `" . TABLE_PANEL_IPSANDPORTS . "`
WHERE `ip` = :ip AND `port` = :port"
);
$result_checkfordouble = Database::pexecute_first($result_checkfordouble_stmt, array('ip' => $ip, 'port' => $port));
if ($result_checkfordouble['id'] != '') {
standard_error('myipnotdouble');
} else {
$ins_stmt = Database::prepare("
INSERT INTO `" . TABLE_PANEL_IPSANDPORTS . "`
SET
`ip` = :ip, `port` = :port, `listen_statement` = :ls,
`namevirtualhost_statement` = :nvhs, `vhostcontainer` = :vhc,
`vhostcontainer_servername_statement` = :vhcss,
`specialsettings` = :ss, `ssl` = :ssl,
`ssl_cert_file` = :ssl_cert, `ssl_key_file` = :ssl_key,
`ssl_ca_file` = :ssl_ca, `ssl_cert_chainfile` = :ssl_chain,
`default_vhostconf_domain` = :dvhd, `docroot` = :docroot;
");
$ins_data = array(
'ip' => $ip,
'port' => $port,
'ls' => $listen_statement,
'nvhs' => $namevirtualhost_statement,
'vhc' => $vhostcontainer,
'vhcss' => $vhostcontainer_servername_statement,
'ss' => $specialsettings,
'ssl' => $ssl,
'ssl_cert' => $ssl_cert_file,
'ssl_key' => $ssl_key_file,
'ssl_ca' => $ssl_ca_file,
'ssl_chain' => $ssl_cert_chainfile,
'dvhd' => $default_vhostconf_domain,
'docroot' => $docroot
);
Database::pexecute($ins_stmt, $ins_data);
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');
// Using nameserver, insert a task which rebuilds the server config
inserttask('4');
redirectTo($filename, Array('page' => $page, 's' => $s));
}
} else { } else {
$ipsandports_add_data = include_once dirname(__FILE__).'/lib/formfields/admin/ipsandports/formfield.ipsandports_add.php'; $ipsandports_add_data = include_once dirname(__FILE__).'/lib/formfields/admin/ipsandports/formfield.ipsandports_add.php';
$ipsandports_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($ipsandports_add_data); $ipsandports_add_form = htmlform::genHTMLForm($ipsandports_add_data);
$title = $ipsandports_add_data['ipsandports_add']['title']; $title = $ipsandports_add_data['ipsandports_add']['title'];
$image = $ipsandports_add_data['ipsandports_add']['image']; $image = $ipsandports_add_data['ipsandports_add']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate("ipsandports/ipsandports_add") . "\";"); eval("echo \"" . getTemplate("ipsandports/ipsandports_add") . "\";");
} }
} elseif ($action == 'edit' && $id != 0) {
try { } elseif($action == 'edit'
$json_result = IpsAndPorts::getLocal($userinfo, array( && $id != 0
'id' => $id ) {
))->get(); $result_stmt = Database::prepare("
} catch (Exception $e) { SELECT * FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = :id"
\Froxlor\UI\Response::dynamic_error($e->getMessage()); );
} $result = Database::pexecute_first($result_stmt, array('id' => $id));
$result = json_decode($json_result, true)['data'];
if ($result['ip'] != '') { if ($result['ip'] != '') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send'])
try { && $_POST['send'] == 'send'
IpsAndPorts::getLocal($userinfo, $_POST)->update(); ) {
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage()); $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 = isset($_POST['listen_statement']) ? 1 : 0;
$namevirtualhost_statement = isset($_POST['namevirtualhost_statement']) ? 1 : 0;
$vhostcontainer = isset($_POST['vhostcontainer']) ? 1 : 0;
$specialsettings = validate(str_replace("\r\n", "\n", $_POST['specialsettings']), 'specialsettings', '/^[^\0]*$/');
$vhostcontainer_servername_statement = isset($_POST['vhostcontainer_servername_statement']) ? 1 : 0;
$default_vhostconf_domain = validate(str_replace("\r\n", "\n", $_POST['default_vhostconf_domain']), 'default_vhostconf_domain', '/^[^\0]*$/');
$docroot = validate($_POST['docroot'], 'docroot');
$result_checkfordouble_stmt = Database::prepare("
SELECT `id` FROM `" . TABLE_PANEL_IPSANDPORTS . "`
WHERE `ip` = :ip AND `port` = :port"
);
$result_checkfordouble = Database::pexecute_first($result_checkfordouble_stmt, array('ip' => $ip, 'port' => $port));
$result_sameipotherport_stmt = Database::prepare("
SELECT `id` FROM `" . TABLE_PANEL_IPSANDPORTS . "`
WHERE `ip` = :ip AND `id` <> :id"
);
$result_sameipotherport = Database::pexecute_first($result_sameipotherport_stmt, array('ip' => $ip, 'id' => $id));
if ((int)Settings::Get('system.use_ssl') == 1
&& isset($_POST['ssl'])
&& $_POST['ssl'] != 0
) {
$ssl = 1;
$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');
$ssl_cert_chainfile = validate($_POST['ssl_cert_chainfile'], 'ssl_cert_chainfile');
} else {
$ssl = 0;
$ssl_cert_file = '';
$ssl_key_file = '';
$ssl_ca_file = '';
$ssl_cert_chainfile = '';
} }
\Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page, if ($listen_statement != '1') {
's' => $s $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 ($ssl_cert_chainfile != '') {
$ssl_cert_chainfile = makeCorrectFile($ssl_cert_chainfile);
}
if (strlen(trim($docroot)) > 0) {
$docroot = makeCorrectDir($docroot);
} else {
$docroot = '';
}
if ($result['ip'] != $ip
&& $result['ip'] == Settings::Get('system.ipaddress')
&& $result_sameipotherport['id'] == ''
) {
standard_error('cantchangesystemip');
} elseif($result_checkfordouble['id'] != ''
&& $result_checkfordouble['id'] != $id
) {
standard_error('myipnotdouble');
} else { } else {
$result = \Froxlor\PhpHelper::htmlentitiesArray($result); $upd_stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_IPSANDPORTS . "`
SET
`ip` = :ip, `port` = :port, `listen_statement` = :ls,
`namevirtualhost_statement` = :nvhs, `vhostcontainer` = :vhc,
`vhostcontainer_servername_statement` = :vhcss,
`specialsettings` = :ss, `ssl` = :ssl,
`ssl_cert_file` = :ssl_cert, `ssl_key_file` = :ssl_key,
`ssl_ca_file` = :ssl_ca, `ssl_cert_chainfile` = :ssl_chain,
`default_vhostconf_domain` = :dvhd, `docroot` = :docroot
WHERE `id` = :id;
");
$upd_data = array(
'ip' => $ip,
'port' => $port,
'ls' => $listen_statement,
'nvhs' => $namevirtualhost_statement,
'vhc' => $vhostcontainer,
'vhcss' => $vhostcontainer_servername_statement,
'ss' => $specialsettings,
'ssl' => $ssl,
'ssl_cert' => $ssl_cert_file,
'ssl_key' => $ssl_key_file,
'ssl_ca' => $ssl_ca_file,
'ssl_chain' => $ssl_cert_chainfile,
'dvhd' => $default_vhostconf_domain,
'docroot' => $docroot,
'id' => $id
);
Database::pexecute($upd_stmt, $upd_data);
$log->logAction(ADM_ACTION, LOG_WARNING, "changed IP/port from '" . $result['ip'] . ":" . $result['port'] . "' to '" . $ip . ":" . $port . "'");
inserttask('1');
// Using nameserver, insert a task which rebuilds the server config
inserttask('4');
redirectTo($filename, Array('page' => $page, 's' => $s));
}
} else {
$result = htmlentities_array($result);
$ipsandports_edit_data = include_once dirname(__FILE__).'/lib/formfields/admin/ipsandports/formfield.ipsandports_edit.php'; $ipsandports_edit_data = include_once dirname(__FILE__).'/lib/formfields/admin/ipsandports/formfield.ipsandports_edit.php';
$ipsandports_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($ipsandports_edit_data); $ipsandports_edit_form = htmlform::genHTMLForm($ipsandports_edit_data);
$title = $ipsandports_edit_data['ipsandports_edit']['title']; $title = $ipsandports_edit_data['ipsandports_edit']['title'];
$image = $ipsandports_edit_data['ipsandports_edit']['image']; $image = $ipsandports_edit_data['ipsandports_edit']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate("ipsandports/ipsandports_edit") . "\";"); eval("echo \"" . getTemplate("ipsandports/ipsandports_edit") . "\";");
} }
} }
} elseif ($action == 'jqCheckIP') {
$ip = $_POST['ip'] ?? "";
if ((filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) || filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) && filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE | FILTER_FLAG_NO_PRIV_RANGE) == false) {
// returns notice if private network detected so we can display it
echo json_encode($lng['admin']['ipsandports']['ipnote']);
} else {
echo 0;
}
exit();
} }
} }

View File

@@ -16,12 +16,13 @@
* @package Panel * @package Panel
* *
*/ */
define('AREA', 'admin'); define('AREA', 'admin');
require './lib/init.php'; require './lib/init.php';
use Froxlor\Api\Commands\SysLog; if ($page == 'log'
&& $userinfo['change_serversettings'] == '1'
if ($page == 'log' && $userinfo['change_serversettings'] == '1') { ) {
if ($action == '') { if ($action == '') {
$fields = array( $fields = array(
'date' => $lng['logger']['date'], 'date' => $lng['logger']['date'],
@@ -29,37 +30,37 @@ if ($page == 'log' && $userinfo['change_serversettings'] == '1') {
'user' => $lng['logger']['user'], 'user' => $lng['logger']['user'],
'text' => $lng['logger']['action'] 'text' => $lng['logger']['action']
); );
try { $paging = new paging($userinfo, TABLE_PANEL_LOG, $fields, null, null, 0, 'desc', 30);
// get total count $query = 'SELECT * FROM `' . TABLE_PANEL_LOG . '` ' . $paging->getSqlWhere(false) . ' ' . $paging->getSqlOrderBy();
$json_result = SysLog::getLocal($userinfo)->listingCount(); $result_stmt = Database::query($query . ' ' . $paging->getSqlLimit());
$result = json_decode($json_result, true)['data']; $result_cnt_stmt = Database::query($query);
// initialize pagination and filtering $logs_count = $result_cnt_stmt->rowCount();
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result); $paging->setEntries($logs_count);
// get list
$json_result = SysLog::getLocal($userinfo, $paging->getApiCommandParams())->listing();
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$sortcode = $paging->getHtmlSortCode($lng); $sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s); $arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng); $searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s); $pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$clog = array(); $clog = array();
foreach ($result['list'] as $row) { while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
if (! isset($clog[$row['action']]) || ! is_array($clog[$row['action']])) {
if (!isset($clog[$row['action']])
|| !is_array($clog[$row['action']])
) {
$clog[$row['action']] = array(); $clog[$row['action']] = array();
} }
$clog[$row['action']][$row['logid']] = $row; $clog[$row['action']][$row['logid']] = $row;
} }
if ($paging->sortfield == 'date' && $paging->sortorder == 'desc') { if ($paging->sortfield == 'date'
&& $paging->sortorder == 'desc'
) {
krsort($clog); krsort($clog);
} else { } else {
ksort($clog); ksort($clog);
} }
$i = 0;
$count = 0; $count = 0;
$log_count = 0; $log_count = 0;
$log = ''; $log = '';
@@ -67,27 +68,27 @@ if ($page == 'log' && $userinfo['change_serversettings'] == '1') {
$_action = 0; $_action = 0;
foreach ($logrows as $row) { foreach ($logrows as $row) {
// if ($paging->checkDisplay($i)) { // if ($paging->checkDisplay($i)) {
$row = \Froxlor\PhpHelper::htmlentitiesArray($row); $row = htmlentities_array($row);
$row['date'] = date("d.m.y H:i:s", $row['date']); $row['date'] = date("d.m.y H:i:s", $row['date']);
if ($_action != $action) { if ($_action != $action) {
switch ($action) { switch ($action) {
case \Froxlor\FroxlorLogger::USR_ACTION: case USR_ACTION:
$_action = $lng['admin']['customer']; $_action = $lng['admin']['customer'];
break; break;
case \Froxlor\FroxlorLogger::RES_ACTION: case RES_ACTION:
$_action = $lng['logger']['reseller']; $_action = $lng['logger']['reseller'];
break; break;
case \Froxlor\FroxlorLogger::ADM_ACTION: case ADM_ACTION:
$_action = $lng['logger']['admin']; $_action = $lng['logger']['admin'];
break; break;
case \Froxlor\FroxlorLogger::CRON_ACTION: case CRON_ACTION:
$_action = $lng['logger']['cron']; $_action = $lng['logger']['cron'];
break; break;
case \Froxlor\FroxlorLogger::LOGIN_ACTION: case LOGIN_ACTION:
$_action = $lng['logger']['login']; $_action = $lng['logger']['login'];
break; break;
case \Froxlor\FroxlorLogger::LOG_ERROR: case LOG_ERROR:
$_action = $lng['logger']['intern']; $_action = $lng['logger']['intern'];
break; break;
default: default:
@@ -96,37 +97,36 @@ if ($page == 'log' && $userinfo['change_serversettings'] == '1') {
} }
$row['action'] = $_action; $row['action'] = $_action;
eval("\$log.=\"" . \Froxlor\UI\Template::getTemplate('logger/logger_action') . "\";"); eval("\$log.=\"" . getTemplate('logger/logger_action') . "\";");
} }
$log_count++; $log_count++;
$row['type'] = \Froxlor\FroxlorLogger::getInstanceOf()->getLogLevelDesc($row['type']); $row['type'] = getLogLevelDesc($row['type']);
eval("\$log.=\"" . \Froxlor\UI\Template::getTemplate('logger/logger_log') . "\";"); eval("\$log.=\"" . getTemplate('logger/logger_log') . "\";");
$count++; $count++;
$_action = $action; $_action = $action;
// }
$i++;
} }
$i++;
} }
eval("echo \"" . \Froxlor\UI\Template::getTemplate('logger/logger') . "\";"); eval("echo \"" . getTemplate('logger/logger') . "\";");
} elseif ($action == 'truncate') { } elseif ($action == 'truncate') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send'])
try { && $_POST['send'] == 'send'
SysLog::getLocal($userinfo, array( ) {
'min_to_keep' => 10 $truncatedate = time() - (60 * 10);
))->delete(); $trunc_stmt = Database::prepare("
} catch (Exception $e) { DELETE FROM `" . TABLE_PANEL_LOG . "` WHERE `date` < :trunc"
\Froxlor\UI\Response::dynamic_error($e->getMessage()); );
} Database::pexecute($trunc_stmt, array('trunc' => $truncatedate));
\Froxlor\UI\Response::redirectTo($filename, array( $log->logAction(ADM_ACTION, LOG_WARNING, 'truncated the system-log (mysql)');
'page' => $page, redirectTo($filename, array('page' => $page, 's' => $s));
's' => $s
));
} else { } else {
\Froxlor\UI\HTML::askYesNo('logger_reallytruncate', $filename, array( ask_yesno('logger_reallytruncate', $filename, array('page' => $page, 'action' => $action), TABLE_PANEL_LOG);
'page' => $page,
'action' => $action
), TABLE_PANEL_LOG);
} }
} }
} }

View File

@@ -16,11 +16,10 @@
* @package Panel * @package Panel
* *
*/ */
define('AREA', 'admin'); define('AREA', 'admin');
require './lib/init.php'; require './lib/init.php';
use Froxlor\Database\Database;
if (isset($_POST['id'])) { if (isset($_POST['id'])) {
$id = intval($_POST['id']); $id = intval($_POST['id']);
} elseif (isset($_GET['id'])) { } elseif (isset($_GET['id'])) {
@@ -29,27 +28,30 @@ if (isset($_POST['id'])) {
if ($page == 'message') { if ($page == 'message') {
if ($action == '') { if ($action == '') {
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'viewed panel_message'); $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(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'sending messages to admins'); ) {
if ($_POST['receipient'] == 0
&& $userinfo['customers_see_all'] == '1'
) {
$log->logAction(ADM_ACTION, LOG_NOTICE, 'sending messages to admins');
$result = Database::query('SELECT `name`, `email` FROM `' . TABLE_PANEL_ADMINS . "`"); $result = Database::query('SELECT `name`, `email` FROM `' . TABLE_PANEL_ADMINS . "`");
} elseif ($_POST['recipient'] == 1) { } elseif ($_POST['receipient'] == 1) {
if ($userinfo['customers_see_all'] == '1') { if ($userinfo['customers_see_all'] == '1') {
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'sending messages to ALL customers'); $log->logAction(ADM_ACTION, LOG_NOTICE, 'sending messages to ALL customers');
$result = Database::query('SELECT `firstname`, `name`, `company`, `email` FROM `' . TABLE_PANEL_CUSTOMERS . "`"); $result = Database::query('SELECT `firstname`, `name`, `company`, `email` FROM `' . TABLE_PANEL_CUSTOMERS . "`");
} else { } else {
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'sending messages to customers'); $log->logAction(ADM_ACTION, LOG_NOTICE, 'sending messages to customers');
$result = Database::prepare(' $result = Database::prepare('
SELECT `firstname`, `name`, `company`, `email` FROM `' . TABLE_PANEL_CUSTOMERS . "` SELECT `firstname`, `name`, `company`, `email` FROM `' . TABLE_PANEL_CUSTOMERS . "`
WHERE `adminid` = :adminid"); WHERE `adminid` = :adminid"
Database::pexecute($result, array( );
'adminid' => $userinfo['adminid'] Database::pexecute($result, array('adminid' => $userinfo['adminid']));
));
} }
} else { } else {
\Froxlor\UI\Response::standard_error('norecipientsgiven'); standard_error('noreceipientsgiven');
} }
$subject = $_POST['subject']; $subject = $_POST['subject'];
@@ -64,11 +66,7 @@ if ($page == 'message') {
$row['firstname'] = isset($row['firstname']) ? $row['firstname'] : ''; $row['firstname'] = isset($row['firstname']) ? $row['firstname'] : '';
$row['company'] = isset($row['company']) ? $row['company'] : ''; $row['company'] = isset($row['company']) ? $row['company'] : '';
$mail->AddAddress($row['email'], \Froxlor\User::getCorrectUserSalutation(array( $mail->AddAddress($row['email'], getCorrectUserSalutation(array('firstname' => $row['firstname'], 'name' => $row['name'], 'company' => $row['company'])));
'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 = (isset($userinfo['firstname']) ? $userinfo['firstname'] . ' ' : '') . $userinfo['name'];
@@ -79,22 +77,17 @@ if ($page == 'message') {
$mailerr_msg = $row['email']; $mailerr_msg = $row['email'];
} }
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_ERR, 'Error sending mail: ' . $mailerr_msg); $log->logAction(ADM_ACTION, LOG_ERR, 'Error sending mail: ' . $mailerr_msg);
\Froxlor\UI\Response::standard_error('errorsendingmail', $row['email']); standard_error('errorsendingmail', $row['email']);
} }
$mailcounter++; $mailcounter++;
$mail->ClearAddresses(); $mail->ClearAddresses();
} }
\Froxlor\UI\Response::redirectTo($filename, array( redirectTo($filename, array('page' => $page, 's' => $s, 'action' => 'showsuccess', 'sentitems' => $mailcounter));
'page' => $page,
's' => $s,
'action' => 'showsuccess',
'sentitems' => $mailcounter
));
} else { } else {
\Froxlor\UI\Response::standard_error('nomessagetosend'); standard_error('nomessagetosend');
} }
} }
} }
@@ -105,10 +98,11 @@ if ($page == 'message') {
$sentitems = isset($_GET['sentitems']) ? (int)$_GET['sentitems'] : 0; $sentitems = isset($_GET['sentitems']) ? (int)$_GET['sentitems'] : 0;
if ($sentitems == 0) { if ($sentitems == 0) {
$successmessage = $lng['message']['norecipients']; $successmessage = $lng['message']['noreceipients'];
} else { } else {
$successmessage = str_replace('%s', $sentitems, $lng['message']['success']); $successmessage = str_replace('%s', $sentitems, $lng['message']['success']);
} }
} else { } else {
$success = 0; $success = 0;
$sentitems = 0; $sentitems = 0;
@@ -116,12 +110,12 @@ if ($page == 'message') {
} }
$action = ''; $action = '';
$recipients = ''; $receipients = '';
if ($userinfo['customers_see_all'] == '1') { if ($userinfo['customers_see_all'] == '1') {
$recipients .= \Froxlor\UI\HTML::makeoption($lng['panel']['reseller'], 0); $receipients.= makeoption($lng['panel']['reseller'], 0);
} }
$recipients .= \Froxlor\UI\HTML::makeoption($lng['panel']['customer'], 1); $receipients .= makeoption($lng['panel']['customer'], 1);
eval("echo \"" . \Froxlor\UI\Template::getTemplate('message/message') . "\";"); eval("echo \"" . getTemplate('message/message') . "\";");
} }

View File

@@ -17,29 +17,33 @@
* Based on https://github.com/amnuts/opcache-gui * Based on https://github.com/amnuts/opcache-gui
* *
*/ */
define('AREA', 'admin'); define('AREA', 'admin');
require './lib/init.php'; require './lib/init.php';
if ($action == 'reset' && function_exists('opcache_reset') && $userinfo['change_serversettings'] == '1') {
if ($action == 'reset' &&
function_exists('opcache_reset') &&
$userinfo['change_serversettings'] == '1'
) {
opcache_reset(); opcache_reset();
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "reset OPcache"); $log->logAction(ADM_ACTION, LOG_INFO, "reseted OPcache");
header('Location: ' . $linker->getLink(array( header('Location: ' . $linker->getLink(array('section' => 'opcacheinfo', 'page' => 'showinfo')));
'section' => 'opcacheinfo',
'page' => 'showinfo'
)));
exit(); exit();
} }
if (! function_exists('opcache_get_configuration')) { if (!function_exists('opcache_get_configuration')
\Froxlor\UI\Response::standard_error($lng['error']['no_opcacheinfo']); ) {
standard_error($lng['error']['no_opcacheinfo']);
} }
if ($page == 'showinfo') { if ($page == 'showinfo'
) {
$opcache_info = opcache_get_configuration(); $opcache_info = opcache_get_configuration();
$opcache_status = opcache_get_status(false); $opcache_status = opcache_get_status(false);
$time = time(); $time = time();
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed OPcache info"); $log->logAction(ADM_ACTION, LOG_NOTICE, "viewed OPcache info");
$runtimelines = ''; $runtimelines = '';
if (isset($opcache_info['directives']) && is_array($opcache_info['directives'])) { if (isset($opcache_info['directives']) && is_array($opcache_info['directives'])) {
@@ -64,7 +68,7 @@ if ($page == 'showinfo') {
$value=number_format($value,0,'.',' '); $value=number_format($value,0,'.',' ');
} }
$name=str_replace('_', ' ', $name); $name=str_replace('_', ' ', $name);
eval("\$runtimelines.=\"" . \Froxlor\UI\Template::getTemplate("settings/opcacheinfo/runtime_line") . "\";"); eval("\$runtimelines.=\"" . getTemplate("settings/opcacheinfo/runtime_line") . "\";");
} }
} }
@@ -81,11 +85,14 @@ if ($page == 'showinfo') {
'oom_restarts' => number_format(@$opcache_status['opcache_statistics']['oom_restarts'] ?: 0,0,'.',' '), 'oom_restarts' => number_format(@$opcache_status['opcache_statistics']['oom_restarts'] ?: 0,0,'.',' '),
'hash_restarts' => number_format(@$opcache_status['opcache_statistics']['hash_restarts'] ?: 0,0,'.',' '), 'hash_restarts' => number_format(@$opcache_status['opcache_statistics']['hash_restarts'] ?: 0,0,'.',' '),
'manual_restarts' => number_format(@$opcache_status['opcache_statistics']['manual_restarts'] ?: 0,0,'.',' '), 'manual_restarts' => number_format(@$opcache_status['opcache_statistics']['manual_restarts'] ?: 0,0,'.',' '),
'status' => (@$opcache_status['restart_in_progress'] ? $lng['opcacheinfo']['restartinprogress'] : (@$opcache_status['restart_pending'] ? $lng['opcacheinfo']['restartpending'] : (@$opcache_status['cache_full'] ? $lng['opcacheinfo']['cachefull'] : (@$opcache_status['opcache_enabled'] ? $lng['opcacheinfo']['enabled'] : $lng['opcacheinfo']['novalue'])))), 'status' => (@$opcache_status['restart_in_progress'] ? $lng['opcacheinfo']['restartinprogress'] :
(@$opcache_status['restart_pending'] ? $lng['opcacheinfo']['restartpending'] :
(@$opcache_status['cache_full'] ? $lng['opcacheinfo']['cachefull'] :
(@$opcache_status['opcache_enabled'] ? $lng['opcacheinfo']['enabled'] : $lng['opcacheinfo']['novalue'])))),
'cachedscripts' => number_format(@$opcache_status['opcache_statistics']['num_cached_scripts'] ?: 0,0,'.',' '), 'cachedscripts' => number_format(@$opcache_status['opcache_statistics']['num_cached_scripts'] ?: 0,0,'.',' '),
'cachehits' => number_format($cachehits,0,'.',' ') . ($cachetotal>0 ? sprintf(" (%.1f %%)", $cachehits/($cachetotal)*100) : ''), 'cachehits' => number_format($cachehits,0,'.',' ') . ($cachetotal>0 ? sprintf(" (%.1f %%)", $cachehits/($cachetotal)*100) : ''),
'cachemiss' => number_format($cachemiss,0,'.',' ') . ($cachetotal>0 ? sprintf(" (%.1f %%)", $cachemiss/($cachetotal)*100) : ''), 'cachemiss' => number_format($cachemiss,0,'.',' ') . ($cachetotal>0 ? sprintf(" (%.1f %%)", $cachemiss/($cachetotal)*100) : ''),
'blacklistmiss' => number_format($blacklistmiss, 0, '.', ' ') . ($cachetotal > 0 ? sprintf(" (%.1f %%)", $blacklistmiss / ($cachetotal) * 100) : '') 'blacklistmiss' => number_format($blacklistmiss,0,'.',' ') . ($cachetotal>0 ? sprintf(" (%.1f %%)", $blacklistmiss/($cachetotal)*100) : ''),
); );
$usedmem=@$opcache_status['memory_usage']['used_memory'] ?: 0; $usedmem=@$opcache_status['memory_usage']['used_memory'] ?: 0;
@@ -100,7 +107,7 @@ if ($page == 'showinfo') {
'total' => bsize($totalmem), 'total' => bsize($totalmem),
'used' => $usedmemstr . ($totalmem>0 ? sprintf(" (%.1f %%)", $usedmem/($totalmem)*100) : ''), 'used' => $usedmemstr . ($totalmem>0 ? sprintf(" (%.1f %%)", $usedmem/($totalmem)*100) : ''),
'free' => $freememstr . ($totalmem>0 ? sprintf(" (%.1f %%)", $freemem/($totalmem)*100) : ''), 'free' => $freememstr . ($totalmem>0 ? sprintf(" (%.1f %%)", $freemem/($totalmem)*100) : ''),
'wasted' => $wastedmemstr . ($totalmem > 0 ? sprintf(" (%.1f %%)", $wastedmem / ($totalmem) * 100) : '') 'wasted' => $wastedmemstr . ($totalmem>0 ? sprintf(" (%.1f %%)", $wastedmem/($totalmem)*100) : ''),
); );
} }
@@ -114,7 +121,7 @@ if ($page == 'showinfo') {
'total' => bsize($totalstring), 'total' => bsize($totalstring),
'used' => $usedstringstr . ($totalstring>0 ? sprintf(" (%.1f %%)", $usedstring/$totalstring*100) : ''), 'used' => $usedstringstr . ($totalstring>0 ? sprintf(" (%.1f %%)", $usedstring/$totalstring*100) : ''),
'free' => $freestringstr . ($totalstring>0 ? sprintf(" (%.1f %%)", $freestring/$totalstring*100) : ''), 'free' => $freestringstr . ($totalstring>0 ? sprintf(" (%.1f %%)", $freestring/$totalstring*100) : ''),
'strcount' => number_format(@$opcache_status['interned_strings_usage']['number_of_strings'] ?: 0, 0, '.', ' ') 'strcount' => number_format(@$opcache_status['interned_strings_usage']['number_of_strings'] ?: 0,0,'.',' '),
); );
} }
@@ -126,28 +133,23 @@ if ($page == 'showinfo') {
$keystat=array( $keystat=array(
'total' => number_format($totalkey,0,'.',' '), 'total' => number_format($totalkey,0,'.',' '),
'used' => $usedkeystr . ($totalkey>0 ? sprintf(" (%.1f %%)", $usedkey/($totalkey)*100) : ''), 'used' => $usedkeystr . ($totalkey>0 ? sprintf(" (%.1f %%)", $usedkey/($totalkey)*100) : ''),
'wasted' => number_format($wastedkey, 0, '.', ' ') . ($totalkey > 0 ? sprintf(" (%.1f %%)", $wastedkey / ($totalkey) * 100) : '') 'wasted' => number_format($wastedkey,0,'.',' ') . ($totalkey>0 ? sprintf(" (%.1f %%)", $wastedkey/($totalkey)*100) : ''),
); );
} }
$blacklistlines = ''; $blacklistlines = '';
if (isset($opcache_info['blacklist']) && is_array($opcache_info['blacklist'])) { if (isset($opcache_info['blacklist']) && is_array($opcache_info['blacklist'])) {
foreach ($opcache_info['blacklist'] as $value) { foreach ($opcache_info['blacklist'] as $value) {
eval("\$blacklistlines.=\"" . \Froxlor\UI\Template::getTemplate("settings/opcacheinfo/blacklist_line") . "\";"); eval("\$blacklistlines.=\"" . getTemplate("settings/opcacheinfo/blacklist_line") . "\";");
} }
} }
eval("echo \"" . \Froxlor\UI\Template::getTemplate("settings/opcacheinfo/showinfo") . "\";"); eval("echo \"" . getTemplate("settings/opcacheinfo/showinfo") . "\";");
} }
function bsize($s) function bsize($s) {
{ foreach (array('', 'K', 'M', 'G') as $i => $k) {
foreach (array(
'',
'K',
'M',
'G'
) as $i => $k) {
if ($s < 1024) if ($s < 1024)
break; break;
$s/=1024; $s/=1024;

View File

@@ -19,10 +19,6 @@
define('AREA', 'admin'); define('AREA', 'admin');
require './lib/init.php'; require './lib/init.php';
use Froxlor\Database\Database;
use Froxlor\Api\Commands\PhpSettings as PhpSettings;
use Froxlor\Api\Commands\FpmDaemons as FpmDaemons;
if (isset($_POST['id'])) { if (isset($_POST['id'])) {
$id = intval($_POST['id']); $id = intval($_POST['id']);
} elseif (isset($_GET['id'])) { } elseif (isset($_GET['id'])) {
@@ -33,36 +29,74 @@ if ($page == 'overview') {
if ($action == '') { if ($action == '') {
try {
$json_result = PhpSettings::getLocal($userinfo, array(
'with_subdomains' => true
))->listing();
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$tablecontent = ''; $tablecontent = '';
$count = 0; $count = 0;
if (isset($result['count']) && $result['count'] > 0) { $result = Database::query("
foreach ($result['list'] as $row) { SELECT c.*, fd.description as fpmdesc
if (isset($row['is_default']) && $row['is_default'] == true) { FROM `" . TABLE_PANEL_PHPCONFIGS . "` c
$row['description'] = "<b>" . $row['description'] . "</b>"; LEFT JOIN `" . TABLE_PANEL_FPMDAEMONS . "` fd ON fd.id = c.fpmsettingid
ORDER BY c.description ASC
");
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$domainresult = false;
$query_params = array(
'id' => $row['id']
);
$query = "SELECT * FROM `" . TABLE_PANEL_DOMAINS . "`
WHERE `phpsettingid` = :id
AND `parentdomainid` = '0'";
if ((int) $userinfo['domains_see_all'] == 0) {
$query .= " AND `adminid` = :adminid";
$query_params['adminid'] = $userinfo['adminid'];
} }
$domains = "";
$subdomains_count = count($row['subdomains']); if ((int) Settings::Get('panel.phpconfigs_hidestdsubdomain') == 1) {
foreach ($row['domains'] as $configdomain) { $ssdids_res = Database::query("
$domains .= $idna_convert->decode($configdomain) . "<br>"; SELECT DISTINCT `standardsubdomain` FROM `" . TABLE_PANEL_CUSTOMERS . "`
WHERE `standardsubdomain` > 0 ORDER BY `standardsubdomain` ASC;");
$ssdids = array();
while ($ssd = $ssdids_res->fetch(PDO::FETCH_ASSOC)) {
$ssdids[] = $ssd['standardsubdomain'];
} }
$count ++; if (count($ssdids) > 0) {
if ($subdomains_count == 0 && empty($domains)) { $query .= " AND `id` NOT IN (" . implode(', ', $ssdids) . ")";
$domains = $lng['admin']['phpsettings']['notused'];
}
eval("\$tablecontent.=\"" . \Froxlor\UI\Template::getTemplate("phpconfig/overview_overview") . "\";");
} }
} }
eval("echo \"" . \Froxlor\UI\Template::getTemplate("phpconfig/overview") . "\";"); $domainresult_stmt = Database::prepare($query);
Database::pexecute($domainresult_stmt, $query_params);
$domains = '';
if (Database::num_rows() > 0) {
while ($row2 = $domainresult_stmt->fetch(PDO::FETCH_ASSOC)) {
$domains .= $row2['domain'] . '<br/>';
}
}
// check whether we use that config as froxor-vhost config
if (Settings::Get('system.mod_fcgid_defaultini_ownvhost') == $row['id'] || Settings::Get('phpfpm.vhost_defaultini') == $row['id']) {
$domains .= Settings::Get('system.hostname');
}
if ($domains == '') {
$domains = $lng['admin']['phpsettings']['notused'];
}
// check whether this is our default config
if ((Settings::Get('system.mod_fcgid') == '1' && Settings::Get('system.mod_fcgid_defaultini') == $row['id']) || (Settings::Get('phpfpm.enabled') == '1' && Settings::Get('phpfpm.defaultini') == $row['id'])) {
$row['description'] = '<b>' . $row['description'] . '</b>';
}
$count ++;
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 == 'add') { if ($action == 'add') {
@@ -70,109 +104,329 @@ if ($page == 'overview') {
if ((int) $userinfo['change_serversettings'] == 1) { if ((int) $userinfo['change_serversettings'] == 1) {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { $description = validate($_POST['description'], 'description');
PhpSettings::getLocal($userinfo, $_POST)->add(); $phpsettings = validate(str_replace("\r\n", "\n", $_POST['phpsettings']), 'phpsettings', '/^[^\0]*$/');
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage()); if (Settings::Get('system.mod_fcgid') == 1) {
$binary = makeCorrectFile(validate($_POST['binary'], 'binary'));
$file_extensions = validate($_POST['file_extensions'], 'file_extensions', '/^[a-zA-Z0-9\s]*$/');
$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',
''
));
$mod_fcgid_umask = validate($_POST['mod_fcgid_umask'], 'mod_fcgid_umask', '/^[0-9]*$/');
// disable fpm stuff
$fpm_config_id = 1;
$fpm_enableslowlog = 0;
$fpm_reqtermtimeout = 0;
$fpm_reqslowtimeout = 0;
$fpm_pass_authorizationheader = 0;
$override_fpmconfig = 0;
$stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_FPMDAEMONS . "` WHERE `id` = :id");
$def_fpmconfig = Database::pexecute_first($stmt, array(
'id' => $fpm_config_id
));
$pm = $def_fpmconfig['pm'];
$max_children = $def_fpmconfig['max_children'];
$start_servers = $def_fpmconfig['start_servers'];
$min_spare_servers = $def_fpmconfig['min_spare_servers'];
$max_spare_servers = $def_fpmconfig['max_spare_servers'];
$max_requests = $def_fpmconfig['max_requests'];
$idle_timeout = $def_fpmconfig['idle_timeout'];
$limit_extensions = $def_fpmconfig['limit_extensions'];
} elseif (Settings::Get('phpfpm.enabled') == 1) {
$fpm_config_id = intval($_POST['fpmconfig']);
$fpm_enableslowlog = isset($_POST['phpfpm_enable_slowlog']) ? (int) $_POST['phpfpm_enable_slowlog'] : 0;
$fpm_reqtermtimeout = validate($_POST['phpfpm_reqtermtimeout'], 'phpfpm_reqtermtimeout', '/^([0-9]+)(|s|m|h|d)$/');
$fpm_reqslowtimeout = validate($_POST['phpfpm_reqslowtimeout'], 'phpfpm_reqslowtimeout', '/^([0-9]+)(|s|m|h|d)$/');
$fpm_pass_authorizationheader = isset($_POST['phpfpm_pass_authorizationheader']) ? (int) $_POST['phpfpm_pass_authorizationheader'] : 0;
$override_fpmconfig = isset($_POST['override_fpmconfig']) ? (int) $_POST['override_fpmconfig'] : 0;
$pm = $_POST['pm'];
$max_children = isset($_POST['max_children']) ? (int) $_POST['max_children'] : 0;
$start_servers = isset($_POST['start_servers']) ? (int) $_POST['start_servers'] : 0;
$min_spare_servers = isset($_POST['min_spare_servers']) ? (int) $_POST['min_spare_servers'] : 0;
$max_spare_servers = isset($_POST['max_spare_servers']) ? (int) $_POST['max_spare_servers'] : 0;
$max_requests = isset($_POST['max_requests']) ? (int) $_POST['max_requests'] : 0;
$idle_timeout = isset($_POST['idle_timeout']) ? (int) $_POST['idle_timeout'] : 0;
$limit_extensions = validate($_POST['limit_extensions'], 'limit_extensions', '/^(\.[a-z]([a-z0-9]+)\ ?)+$/');
// disable fcgid stuff
$binary = '/usr/bin/php-cgi';
$file_extensions = 'php';
$mod_fcgid_starter = 0;
$mod_fcgid_maxrequests = 0;
$mod_fcgid_umask = "022";
} }
\Froxlor\UI\Response::redirectTo($filename, array(
if (strlen($description) == 0 || strlen($description) > 50) {
standard_error('descriptioninvalid');
}
$ins_stmt = Database::prepare("
INSERT INTO `" . TABLE_PANEL_PHPCONFIGS . "` SET
`description` = :desc,
`binary` = :binary,
`file_extensions` = :fext,
`mod_fcgid_starter` = :starter,
`mod_fcgid_maxrequests` = :mreq,
`mod_fcgid_umask` = :umask,
`fpm_slowlog` = :fpmslow,
`fpm_reqterm` = :fpmreqterm,
`fpm_reqslow` = :fpmreqslow,
`phpsettings` = :phpsettings,
`fpmsettingid` = :fpmsettingid,
`pass_authorizationheader` = :fpmpassauth,
`override_fpmconfig` = :ofc,
`pm` = :pm,
`max_children` = :max_children,
`start_servers` = :start_servers,
`min_spare_servers` = :min_spare_servers,
`max_spare_servers` = :max_spare_servers,
`max_requests` = :max_requests,
`idle_timeout` = :idle_timeout,
`limit_extensions` = :limit_extensions");
$ins_data = array(
'desc' => $description,
'binary' => $binary,
'fext' => $file_extensions,
'starter' => $mod_fcgid_starter,
'mreq' => $mod_fcgid_maxrequests,
'umask' => $mod_fcgid_umask,
'fpmslow' => $fpm_enableslowlog,
'fpmreqterm' => $fpm_reqtermtimeout,
'fpmreqslow' => $fpm_reqslowtimeout,
'phpsettings' => $phpsettings,
'fpmsettingid' => $fpm_config_id,
'fpmpassauth' => $fpm_pass_authorizationheader,
'ofc' => $override_fpmconfig,
'pm' => $pm,
'max_children' => $max_children,
'start_servers' => $start_servers,
'min_spare_servers' => $min_spare_servers,
'max_spare_servers' => $max_spare_servers,
'max_requests' => $max_requests,
'idle_timeout' => $idle_timeout,
'limit_extensions' => $limit_extensions
);
Database::pexecute($ins_stmt, $ins_data);
inserttask('1');
$log->logAction(ADM_ACTION, LOG_INFO, "php.ini setting with description '" . $description . "' has been created by '" . $userinfo['loginname'] . "'");
redirectTo($filename, array(
'page' => $page, 'page' => $page,
's' => $s 's' => $s
)); ));
} else { } else {
if (file_exists(\Froxlor\Froxlor::getInstallDir() . '/templates/misc/php/default.ini.php')) {
require_once \Froxlor\Froxlor::getInstallDir() . '/templates/misc/php/default.ini.php';
$result = [
'phpsettings' => DEFAULT_PHPINI
];
} else {
// use first php-config as fallback
$result_stmt = Database::query("SELECT * FROM `" . TABLE_PANEL_PHPCONFIGS . "` WHERE `id` = 1"); $result_stmt = Database::query("SELECT * FROM `" . TABLE_PANEL_PHPCONFIGS . "` WHERE `id` = 1");
$result = $result_stmt->fetch(PDO::FETCH_ASSOC); $result = $result_stmt->fetch(PDO::FETCH_ASSOC);
}
$fpmconfigs = ''; $fpmconfigs = '';
$configs = Database::query("SELECT * FROM `" . TABLE_PANEL_FPMDAEMONS . "` ORDER BY `description` ASC"); $configs = Database::query("SELECT * FROM `" . TABLE_PANEL_FPMDAEMONS . "` ORDER BY `description` ASC");
while ($row = $configs->fetch(PDO::FETCH_ASSOC)) { while ($row = $configs->fetch(PDO::FETCH_ASSOC)) {
$fpmconfigs .= \Froxlor\UI\HTML::makeoption($row['description'], $row['id'], 1, true, true); $fpmconfigs .= makeoption($row['description'], $row['id'], 1, true, true);
} }
$pm_select = \Froxlor\UI\HTML::makeoption('static', 'static', 'dynamic', true, true); $pm_select = makeoption('static', 'static', 'static', true, true);
$pm_select .= \Froxlor\UI\HTML::makeoption('dynamic', 'dynamic', 'dynamic', true, true); $pm_select.= makeoption('dynamic', 'dynamic', 'static', true, true);
$pm_select .= \Froxlor\UI\HTML::makeoption('ondemand', 'ondemand', 'dynamic', true, true); $pm_select.= makeoption('ondemand', 'ondemand', 'static', true, true);
$phpconfig_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/phpconfig/formfield.phpconfig_add.php'; $phpconfig_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/phpconfig/formfield.phpconfig_add.php';
$phpconfig_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($phpconfig_add_data); $phpconfig_add_form = htmlform::genHTMLForm($phpconfig_add_data);
$title = $phpconfig_add_data['phpconfig_add']['title']; $title = $phpconfig_add_data['phpconfig_add']['title'];
$image = $phpconfig_add_data['phpconfig_add']['image']; $image = $phpconfig_add_data['phpconfig_add']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate("phpconfig/overview_add") . "\";"); eval("echo \"" . getTemplate("phpconfig/overview_add") . "\";");
} }
} else { } else {
\Froxlor\UI\Response::standard_error('nopermissionsorinvalidid'); standard_error('nopermissionsorinvalidid');
} }
} }
if ($action == 'delete') { if ($action == 'delete') {
try { $result_stmt = Database::prepare("
$json_result = PhpSettings::getLocal($userinfo, array( SELECT * FROM `" . TABLE_PANEL_PHPCONFIGS . "` WHERE `id` = :id");
$result = Database::pexecute_first($result_stmt, array(
'id' => $id 'id' => $id
))->get(); ));
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage()); if ((Settings::Get('system.mod_fcgid') == '1' && Settings::Get('system.mod_fcgid_defaultini_ownvhost') == $id) || (Settings::Get('phpfpm.enabled') == '1' && Settings::Get('phpfpm.vhost_defaultini') == $id)) {
standard_error('cannotdeletehostnamephpconfig');
}
if ((Settings::Get('system.mod_fcgid') == '1' && Settings::Get('system.mod_fcgid_defaultini') == $id) || (Settings::Get('phpfpm.enabled') == '1' && Settings::Get('phpfpm.defaultini') == $id)) {
standard_error('cannotdeletedefaultphpconfig');
} }
$result = json_decode($json_result, true)['data'];
if ($result['id'] != 0 && $result['id'] == $id && (int) $userinfo['change_serversettings'] == 1 && $id != 1) // cannot delete the default php.config if ($result['id'] != 0 && $result['id'] == $id && (int) $userinfo['change_serversettings'] == 1 && $id != 1) // cannot delete the default php.config
{ {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { // set php-config to default for all domains using the
PhpSettings::getLocal($userinfo, array( // config that is to be deleted
$upd_stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_DOMAINS . "` SET
`phpsettingid` = '1' WHERE `phpsettingid` = :id");
Database::pexecute($upd_stmt, array(
'id' => $id 'id' => $id
))->delete(); ));
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage()); $del_stmt = Database::prepare("
} DELETE FROM `" . TABLE_PANEL_PHPCONFIGS . "` WHERE `id` = :id");
\Froxlor\UI\Response::redirectTo($filename, array( Database::pexecute($del_stmt, array(
'id' => $id
));
inserttask('1');
$log->logAction(ADM_ACTION, LOG_INFO, "php.ini setting with id #" . (int) $id . " has been deleted by '" . $userinfo['loginname'] . "'");
redirectTo($filename, array(
'page' => $page, 'page' => $page,
's' => $s 's' => $s
)); ));
} else { } else {
\Froxlor\UI\HTML::askYesNo('phpsetting_reallydelete', $filename, array( ask_yesno('phpsetting_reallydelete', $filename, array(
'id' => $id, 'id' => $id,
'page' => $page, 'page' => $page,
'action' => $action 'action' => $action
), $result['description']); ), $result['description']);
} }
} else { } else {
\Froxlor\UI\Response::standard_error('nopermissionsorinvalidid'); standard_error('nopermissionsorinvalidid');
} }
} }
if ($action == 'edit') { if ($action == 'edit') {
try { $result_stmt = Database::prepare("
$json_result = PhpSettings::getLocal($userinfo, array( SELECT * FROM `" . TABLE_PANEL_PHPCONFIGS . "` WHERE `id` = :id");
$result = Database::pexecute_first($result_stmt, array(
'id' => $id 'id' => $id
))->get(); ));
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
if ($result['id'] != 0 && $result['id'] == $id && (int) $userinfo['change_serversettings'] == 1) { if ($result['id'] != 0 && $result['id'] == $id && (int) $userinfo['change_serversettings'] == 1) {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { $description = validate($_POST['description'], 'description');
PhpSettings::getLocal($userinfo, $_POST)->update(); $phpsettings = validate(str_replace("\r\n", "\n", $_POST['phpsettings']), 'phpsettings', '/^[^\0]*$/');
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage()); if (Settings::Get('system.mod_fcgid') == 1) {
$binary = makeCorrectFile(validate($_POST['binary'], 'binary'));
$file_extensions = validate($_POST['file_extensions'], 'file_extensions', '/^[a-zA-Z0-9\s]*$/');
$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',
''
));
$mod_fcgid_umask = validate($_POST['mod_fcgid_umask'], 'mod_fcgid_umask', '/^[0-9]*$/');
// disable fpm stuff
$fpm_config_id = 1;
$fpm_enableslowlog = 0;
$fpm_reqtermtimeout = 0;
$fpm_reqslowtimeout = 0;
$fpm_pass_authorizationheader = 0;
$override_fpmconfig = 0;
$stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_FPMDAEMONS . "` WHERE `id` = :id");
$def_fpmconfig = Database::pexecute_first($stmt, array(
'id' => $fpm_config_id
));
$pm = $def_fpmconfig['pm'];
$max_children = $def_fpmconfig['max_children'];
$start_servers = $def_fpmconfig['start_servers'];
$min_spare_servers = $def_fpmconfig['min_spare_servers'];
$max_spare_servers = $def_fpmconfig['max_spare_servers'];
$max_requests = $def_fpmconfig['max_requests'];
$idle_timeout = $def_fpmconfig['idle_timeout'];
$limit_extensions = $def_fpmconfig['limit_extensions'];
} elseif (Settings::Get('phpfpm.enabled') == 1) {
$fpm_config_id = intval($_POST['fpmconfig']);
$fpm_enableslowlog = isset($_POST['phpfpm_enable_slowlog']) ? (int) $_POST['phpfpm_enable_slowlog'] : 0;
$fpm_reqtermtimeout = validate($_POST['phpfpm_reqtermtimeout'], 'phpfpm_reqtermtimeout', '/^([0-9]+)(|s|m|h|d)$/');
$fpm_reqslowtimeout = validate($_POST['phpfpm_reqslowtimeout'], 'phpfpm_reqslowtimeout', '/^([0-9]+)(|s|m|h|d)$/');
$fpm_pass_authorizationheader = isset($_POST['phpfpm_pass_authorizationheader']) ? (int) $_POST['phpfpm_pass_authorizationheader'] : 0;
$override_fpmconfig = isset($_POST['override_fpmconfig']) ? (int) $_POST['override_fpmconfig'] : $result['override_fpmconfig'];
$pm = $_POST['pm'];
$max_children = isset($_POST['max_children']) ? (int) $_POST['max_children'] : $result['max_children'];
$start_servers = isset($_POST['start_servers']) ? (int) $_POST['start_servers'] : $result['start_servers'];
$min_spare_servers = isset($_POST['min_spare_servers']) ? (int) $_POST['min_spare_servers'] : $result['min_spare_servers'];
$max_spare_servers = isset($_POST['max_spare_servers']) ? (int) $_POST['max_spare_servers'] : $result['max_spare_servers'];
$max_requests = isset($_POST['max_requests']) ? (int) $_POST['max_requests'] : $result['max_requests'];
$idle_timeout = isset($_POST['idle_timeout']) ? (int) $_POST['idle_timeout'] : $result['idle_timeout'];
$limit_extensions = validate($_POST['limit_extensions'], 'limit_extensions', '/^(\.[a-z]([a-z0-9]+)\ ?)+$/');
// disable fcgid stuff
$binary = '/usr/bin/php-cgi';
$file_extensions = 'php';
$mod_fcgid_starter = 0;
$mod_fcgid_maxrequests = 0;
$mod_fcgid_umask = "022";
} }
\Froxlor\UI\Response::redirectTo($filename, array(
if (strlen($description) == 0 || strlen($description) > 50) {
standard_error('descriptioninvalid');
}
$upd_stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_PHPCONFIGS . "` SET
`description` = :desc,
`binary` = :binary,
`file_extensions` = :fext,
`mod_fcgid_starter` = :starter,
`mod_fcgid_maxrequests` = :mreq,
`mod_fcgid_umask` = :umask,
`fpm_slowlog` = :fpmslow,
`fpm_reqterm` = :fpmreqterm,
`fpm_reqslow` = :fpmreqslow,
`phpsettings` = :phpsettings,
`fpmsettingid` = :fpmsettingid,
`pass_authorizationheader` = :fpmpassauth,
`override_fpmconfig` = :ofc,
`pm` = :pm,
`max_children` = :max_children,
`start_servers` = :start_servers,
`min_spare_servers` = :min_spare_servers,
`max_spare_servers` = :max_spare_servers,
`max_requests` = :max_requests,
`idle_timeout` = :idle_timeout,
`limit_extensions` = :limit_extensions
WHERE `id` = :id");
$upd_data = array(
'desc' => $description,
'binary' => $binary,
'fext' => $file_extensions,
'starter' => $mod_fcgid_starter,
'mreq' => $mod_fcgid_maxrequests,
'umask' => $mod_fcgid_umask,
'fpmslow' => $fpm_enableslowlog,
'fpmreqterm' => $fpm_reqtermtimeout,
'fpmreqslow' => $fpm_reqslowtimeout,
'phpsettings' => $phpsettings,
'fpmsettingid' => $fpm_config_id,
'fpmpassauth' => $fpm_pass_authorizationheader,
'ofc' => $override_fpmconfig,
'pm' => $pm,
'max_children' => $max_children,
'start_servers' => $start_servers,
'min_spare_servers' => $min_spare_servers,
'max_spare_servers' => $max_spare_servers,
'max_requests' => $max_requests,
'idle_timeout' => $idle_timeout,
'limit_extensions' => $limit_extensions,
'id' => $id
);
Database::pexecute($upd_stmt, $upd_data);
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, 'page' => $page,
's' => $s 's' => $s
)); ));
@@ -181,49 +435,61 @@ if ($page == 'overview') {
$fpmconfigs = ''; $fpmconfigs = '';
$configs = Database::query("SELECT * FROM `" . TABLE_PANEL_FPMDAEMONS . "` ORDER BY `description` ASC"); $configs = Database::query("SELECT * FROM `" . TABLE_PANEL_FPMDAEMONS . "` ORDER BY `description` ASC");
while ($row = $configs->fetch(PDO::FETCH_ASSOC)) { while ($row = $configs->fetch(PDO::FETCH_ASSOC)) {
$fpmconfigs .= \Froxlor\UI\HTML::makeoption($row['description'], $row['id'], $result['fpmsettingid'], true, true); $fpmconfigs .= makeoption($row['description'], $row['id'], $result['fpmsettingid'], true, true);
} }
$pm_select = \Froxlor\UI\HTML::makeoption('static', 'static', $result['pm'], true, true); $pm_select = makeoption('static', 'static', $result['pm'], true, true);
$pm_select .= \Froxlor\UI\HTML::makeoption('dynamic', 'dynamic', $result['pm'], true, true); $pm_select.= makeoption('dynamic', 'dynamic', $result['pm'], true, true);
$pm_select .= \Froxlor\UI\HTML::makeoption('ondemand', 'ondemand', $result['pm'], true, true); $pm_select.= makeoption('ondemand', 'ondemand', $result['pm'], true, true);
$phpconfig_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/phpconfig/formfield.phpconfig_edit.php'; $phpconfig_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/phpconfig/formfield.phpconfig_edit.php';
$phpconfig_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($phpconfig_edit_data); $phpconfig_edit_form = htmlform::genHTMLForm($phpconfig_edit_data);
$title = $phpconfig_edit_data['phpconfig_edit']['title']; $title = $phpconfig_edit_data['phpconfig_edit']['title'];
$image = $phpconfig_edit_data['phpconfig_edit']['image']; $image = $phpconfig_edit_data['phpconfig_edit']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate("phpconfig/overview_edit") . "\";"); eval("echo \"" . getTemplate("phpconfig/overview_edit") . "\";");
} }
} else { } else {
\Froxlor\UI\Response::standard_error('nopermissionsorinvalidid'); standard_error('nopermissionsorinvalidid');
} }
} }
} elseif ($page == 'fpmdaemons') { } elseif ($page == 'fpmdaemons') {
if ($action == '') { if ($action == '') {
try {
$json_result = FpmDaemons::getLocal($userinfo)->listing();
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$tablecontent = ''; $tablecontent = '';
$count = 0; $count = 0;
if (isset($result['count']) && $result['count'] > 0) { $result = Database::query("SELECT * FROM `" . TABLE_PANEL_FPMDAEMONS . "` ORDER BY `description` ASC");
foreach ($result['list'] as $row) {
$configs = ""; while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
foreach ($row['configs'] as $configused) {
$configs .= $configused . "<br>"; $query_params = array(
'id' => $row['id']
);
$query = "SELECT * FROM `" . TABLE_PANEL_PHPCONFIGS . "` WHERE `fpmsettingid` = :id";
$configresult_stmt = Database::prepare($query);
Database::pexecute($configresult_stmt, $query_params);
$configs = '';
if (Database::num_rows() > 0) {
while ($row2 = $configresult_stmt->fetch(PDO::FETCH_ASSOC)) {
$configs .= $row2['description'] . '<br/>';
} }
}
if ($configs == '') {
$configs = $lng['admin']['phpsettings']['notused'];
}
$count ++; $count ++;
eval("\$tablecontent.=\"" . \Froxlor\UI\Template::getTemplate("phpconfig/fpmdaemons_overview") . "\";"); eval("\$tablecontent.=\"" . getTemplate("phpconfig/fpmdaemons_overview") . "\";");
} }
}
eval("echo \"" . \Froxlor\UI\Template::getTemplate("phpconfig/fpmdaemons") . "\";"); $log->logAction(ADM_ACTION, LOG_INFO, "fpm daemons setting overview has been viewed by '" . $userinfo['loginname'] . "'");
eval("echo \"" . getTemplate("phpconfig/fpmdaemons") . "\";");
} }
if ($action == 'add') { if ($action == 'add') {
@@ -231,112 +497,204 @@ if ($page == 'overview') {
if ((int) $userinfo['change_serversettings'] == 1) { if ((int) $userinfo['change_serversettings'] == 1) {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { $description = validate($_POST['description'], 'description');
FpmDaemons::getLocal($userinfo, $_POST)->add(); $reload_cmd = validate($_POST['reload_cmd'], 'reload_cmd');
} catch (Exception $e) { $config_dir = validate($_POST['config_dir'], 'config_dir');
\Froxlor\UI\Response::dynamic_error($e->getMessage()); $pm = $_POST['pm'];
$max_children = isset($_POST['max_children']) ? (int) $_POST['max_children'] : 0;
$start_servers = isset($_POST['start_servers']) ? (int) $_POST['start_servers'] : 0;
$min_spare_servers = isset($_POST['min_spare_servers']) ? (int) $_POST['min_spare_servers'] : 0;
$max_spare_servers = isset($_POST['max_spare_servers']) ? (int) $_POST['max_spare_servers'] : 0;
$max_requests = isset($_POST['max_requests']) ? (int) $_POST['max_requests'] : 0;
$idle_timeout = isset($_POST['idle_timeout']) ? (int) $_POST['idle_timeout'] : 0;
$limit_extensions = validate($_POST['limit_extensions'], 'limit_extensions', '/^(\.[a-z]([a-z0-9]+)\ ?)+$/');
if (strlen($description) == 0 || strlen($description) > 50) {
standard_error('descriptioninvalid');
} }
\Froxlor\UI\Response::redirectTo($filename, array(
$ins_stmt = Database::prepare("
INSERT INTO `" . TABLE_PANEL_FPMDAEMONS . "` SET
`description` = :desc,
`reload_cmd` = :reload_cmd,
`config_dir` = :config_dir,
`pm` = :pm,
`max_children` = :max_children,
`start_servers` = :start_servers,
`min_spare_servers` = :min_spare_servers,
`max_spare_servers` = :max_spare_servers,
`max_requests` = :max_requests,
`idle_timeout` = :idle_timeout,
`limit_extensions` = :limit_extensions
");
$ins_data = array(
'desc' => $description,
'reload_cmd' => $reload_cmd,
'config_dir' => makeCorrectDir($config_dir),
'pm' => $pm,
'max_children' => $max_children,
'start_servers' => $start_servers,
'min_spare_servers' => $min_spare_servers,
'max_spare_servers' => $max_spare_servers,
'max_requests' => $max_requests,
'idle_timeout' => $idle_timeout,
'limit_extensions' => $limit_extensions
);
Database::pexecute($ins_stmt, $ins_data);
inserttask('1');
$log->logAction(ADM_ACTION, LOG_INFO, "fpm-daemon setting with description '" . $description . "' has been created by '" . $userinfo['loginname'] . "'");
redirectTo($filename, array(
'page' => $page, 'page' => $page,
's' => $s 's' => $s
)); ));
} else { } else {
$pm_select = \Froxlor\UI\HTML::makeoption('static', 'static', 'dynamic', true, true); $pm_select = makeoption('static', 'static', 'static', true, true);
$pm_select .= \Froxlor\UI\HTML::makeoption('dynamic', 'dynamic', 'dynamic', true, true); $pm_select.= makeoption('dynamic', 'dynamic', 'static', true, true);
$pm_select .= \Froxlor\UI\HTML::makeoption('ondemand', 'ondemand', 'dynamic', true, true); $pm_select.= makeoption('ondemand', 'ondemand', 'static', true, true);
$fpmconfig_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/phpconfig/formfield.fpmconfig_add.php'; $fpmconfig_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/phpconfig/formfield.fpmconfig_add.php';
$fpmconfig_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($fpmconfig_add_data); $fpmconfig_add_form = htmlform::genHTMLForm($fpmconfig_add_data);
$title = $fpmconfig_add_data['fpmconfig_add']['title']; $title = $fpmconfig_add_data['fpmconfig_add']['title'];
$image = $fpmconfig_add_data['fpmconfig_add']['image']; $image = $fpmconfig_add_data['fpmconfig_add']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate("phpconfig/fpmconfig_add") . "\";"); eval("echo \"" . getTemplate("phpconfig/fpmconfig_add") . "\";");
} }
} else { } else {
\Froxlor\UI\Response::standard_error('nopermissionsorinvalidid'); standard_error('nopermissionsorinvalidid');
} }
} }
if ($action == 'delete') { if ($action == 'delete') {
try { $result_stmt = Database::prepare("
$json_result = FpmDaemons::getLocal($userinfo, array( SELECT * FROM `" . TABLE_PANEL_FPMDAEMONS . "` WHERE `id` = :id");
$result = Database::pexecute_first($result_stmt, array(
'id' => $id 'id' => $id
))->get(); ));
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
if ($id == 1) { if ($id == 1) {
\Froxlor\UI\Response::standard_error('cannotdeletedefaultphpconfig'); standard_error('cannotdeletedefaultphpconfig');
} }
if ($result['id'] != 0 && $result['id'] == $id && (int) $userinfo['change_serversettings'] == 1 && $id != 1) // cannot delete the default php.config if ($result['id'] != 0 && $result['id'] == $id && (int) $userinfo['change_serversettings'] == 1 && $id != 1) // cannot delete the default php.config
{ {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { // set default fpm daemon config for all php-config that use this config that is to be deleted
FpmDaemons::getLocal($userinfo, $_POST)->delete(); $upd_stmt = Database::prepare("
} catch (Exception $e) { UPDATE `" . TABLE_PANEL_PHPCONFIGS . "` SET
\Froxlor\UI\Response::dynamic_error($e->getMessage()); `fpmsettingid` = '1' WHERE `fpmsettingid` = :id");
} Database::pexecute($upd_stmt, array(
\Froxlor\UI\Response::redirectTo($filename, array( 'id' => $id
));
$del_stmt = Database::prepare("
DELETE FROM `" . TABLE_PANEL_FPMDAEMONS . "` WHERE `id` = :id");
Database::pexecute($del_stmt, array(
'id' => $id
));
inserttask('1');
$log->logAction(ADM_ACTION, LOG_INFO, "fpm-daemon setting with id #" . (int) $id . " has been deleted by '" . $userinfo['loginname'] . "'");
redirectTo($filename, array(
'page' => $page, 'page' => $page,
's' => $s 's' => $s
)); ));
} else { } else {
\Froxlor\UI\HTML::askYesNo('fpmsetting_reallydelete', $filename, array( ask_yesno('fpmsetting_reallydelete', $filename, array(
'id' => $id, 'id' => $id,
'page' => $page, 'page' => $page,
'action' => $action 'action' => $action
), $result['description']); ), $result['description']);
} }
} else { } else {
\Froxlor\UI\Response::standard_error('nopermissionsorinvalidid'); standard_error('nopermissionsorinvalidid');
} }
} }
if ($action == 'edit') { if ($action == 'edit') {
try { $result_stmt = Database::prepare("
$json_result = FpmDaemons::getLocal($userinfo, array( SELECT * FROM `" . TABLE_PANEL_FPMDAEMONS . "` WHERE `id` = :id");
$result = Database::pexecute_first($result_stmt, array(
'id' => $id 'id' => $id
))->get(); ));
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
if ($result['id'] != 0 && $result['id'] == $id && (int) $userinfo['change_serversettings'] == 1) { if ($result['id'] != 0 && $result['id'] == $id && (int) $userinfo['change_serversettings'] == 1) {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { $description = validate($_POST['description'], 'description');
FpmDaemons::getLocal($userinfo, $_POST)->update(); $reload_cmd = validate($_POST['reload_cmd'], 'reload_cmd');
} catch (Exception $e) { $config_dir = validate($_POST['config_dir'], 'config_dir');
\Froxlor\UI\Response::dynamic_error($e->getMessage()); $pm = $_POST['pm'];
$max_children = isset($_POST['max_children']) ? (int) $_POST['max_children'] : $result['max_children'];
$start_servers = isset($_POST['start_servers']) ? (int) $_POST['start_servers'] : $result['start_servers'];
$min_spare_servers = isset($_POST['min_spare_servers']) ? (int) $_POST['min_spare_servers'] : $result['min_spare_servers'];
$max_spare_servers = isset($_POST['max_spare_servers']) ? (int) $_POST['max_spare_servers'] : $result['max_spare_servers'];
$max_requests = isset($_POST['max_requests']) ? (int) $_POST['max_requests'] : $result['max_requests'];
$idle_timeout = isset($_POST['idle_timeout']) ? (int) $_POST['idle_timeout'] : $result['idle_timeout'];
$limit_extensions = validate($_POST['limit_extensions'], 'limit_extensions', '/^(\.[a-z]([a-z0-9]+)\ ?)+$/');
if (strlen($description) == 0 || strlen($description) > 50) {
standard_error('descriptioninvalid');
} }
\Froxlor\UI\Response::redirectTo($filename, array(
$upd_stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_FPMDAEMONS . "` SET
`description` = :desc,
`reload_cmd` = :reload_cmd,
`config_dir` = :config_dir,
`pm` = :pm,
`max_children` = :max_children,
`start_servers` = :start_servers,
`min_spare_servers` = :min_spare_servers,
`max_spare_servers` = :max_spare_servers,
`max_requests` = :max_requests,
`idle_timeout` = :idle_timeout,
`limit_extensions` = :limit_extensions
WHERE `id` = :id
");
$upd_data = array(
'desc' => $description,
'reload_cmd' => $reload_cmd,
'config_dir' => makeCorrectDir($config_dir),
'pm' => $pm,
'max_children' => $max_children,
'start_servers' => $start_servers,
'min_spare_servers' => $min_spare_servers,
'max_spare_servers' => $max_spare_servers,
'max_requests' => $max_requests,
'idle_timeout' => $idle_timeout,
'limit_extensions' => $limit_extensions,
'id' => $id
);
Database::pexecute($upd_stmt, $upd_data);
inserttask('1');
$log->logAction(ADM_ACTION, LOG_INFO, "fpm-daemon setting with description '" . $description . "' has been changed by '" . $userinfo['loginname'] . "'");
redirectTo($filename, array(
'page' => $page, 'page' => $page,
's' => $s 's' => $s
)); ));
} else { } else {
$pm_select = \Froxlor\UI\HTML::makeoption('static', 'static', $result['pm'], true, true); $pm_select = makeoption('static', 'static', $result['pm'], true, true);
$pm_select .= \Froxlor\UI\HTML::makeoption('dynamic', 'dynamic', $result['pm'], true, true); $pm_select.= makeoption('dynamic', 'dynamic', $result['pm'], true, true);
$pm_select .= \Froxlor\UI\HTML::makeoption('ondemand', 'ondemand', $result['pm'], true, true); $pm_select.= makeoption('ondemand', 'ondemand', $result['pm'], true, true);
$fpmconfig_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/phpconfig/formfield.fpmconfig_edit.php'; $fpmconfig_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/phpconfig/formfield.fpmconfig_edit.php';
$fpmconfig_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($fpmconfig_edit_data); $fpmconfig_edit_form = htmlform::genHTMLForm($fpmconfig_edit_data);
$title = $fpmconfig_edit_data['fpmconfig_edit']['title']; $title = $fpmconfig_edit_data['fpmconfig_edit']['title'];
$image = $fpmconfig_edit_data['fpmconfig_edit']['image']; $image = $fpmconfig_edit_data['fpmconfig_edit']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate("phpconfig/fpmconfig_edit") . "\";"); eval("echo \"" . getTemplate("phpconfig/fpmconfig_edit") . "\";");
} }
} else { } else {
\Froxlor\UI\Response::standard_error('nopermissionsorinvalidid'); standard_error('nopermissionsorinvalidid');
} }
} }
} }

View File

@@ -17,10 +17,6 @@
define('AREA', 'admin'); define('AREA', 'admin');
require './lib/init.php'; require './lib/init.php';
use Froxlor\Api\Commands\HostingPlans;
use Froxlor\Database\Database;
use Froxlor\Settings;
if (isset($_POST['id'])) { if (isset($_POST['id'])) {
$id = intval($_POST['id']); $id = intval($_POST['id']);
} elseif (isset($_GET['id'])) { } elseif (isset($_GET['id'])) {
@@ -31,100 +27,202 @@ if ($page == '' || $page == 'overview') {
if ($action == '') { if ($action == '') {
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_plans"); $log->logAction(ADM_ACTION, LOG_NOTICE, "viewed admin_plans");
$fields = array( $fields = array(
'p.name' => $lng['admin']['plans']['name'], 'p.name' => $lng['admin']['plans']['name'],
'p.description' => $lng['admin']['plans']['description'], 'p.description' => $lng['admin']['plans']['description'],
'adminname' => $lng['admin']['admin'], 'adminname' => $lng['admin']['admin'],
'p.ts' => $lng['admin']['plans']['last_update'] 'p.ts' => $lng['admin']['plans']['last_update']
); );
try { $paging = new paging($userinfo, TABLE_PANEL_PLANS, $fields);
// get total count
$json_result = HostingPlans::getLocal($userinfo)->listingCount();
$result = json_decode($json_result, true)['data'];
// initialize pagination and filtering
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
// get list
$json_result = HostingPlans::getLocal($userinfo, $paging->getApiCommandParams())->listing();
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$plans = ''; $plans = '';
$result_stmt = Database::prepare("
SELECT p.*, a.loginname as adminname
FROM `" . TABLE_PANEL_PLANS . "` p, `" . TABLE_PANEL_ADMINS . "` a
WHERE " . ($userinfo['customers_see_all'] ? '' : " `p`.`adminid` = :adminid AND ") . "
`p`.`adminid` = `a`.`adminid` " . $paging->getSqlWhere(false) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
Database::pexecute($result_stmt, array(
'adminid' => $userinfo['adminid']
));
$paging->setEntries(Database::num_rows());
$sortcode = $paging->getHtmlSortCode($lng); $sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s); $arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng); $searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s); $pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$i = 0;
$count = 0; $count = 0;
foreach ($result['list'] as $row) { while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
if ($paging->checkDisplay($i)) {
$row = htmlentities_array($row);
$row['ts_format'] = date("d.m.Y H:i", $row['ts']); $row['ts_format'] = date("d.m.Y H:i", $row['ts']);
eval("\$plans.=\"" . \Froxlor\UI\Template::getTemplate("plans/plans_plan") . "\";"); eval("\$plans.=\"" . getTemplate("plans/plans_plan") . "\";");
$count ++; $count ++;
} }
$i ++;
}
eval("echo \"" . \Froxlor\UI\Template::getTemplate("plans/plans") . "\";"); eval("echo \"" . getTemplate("plans/plans") . "\";");
} elseif ($action == 'delete' && $id != 0) { } elseif ($action == 'delete' && $id != 0) {
try { $result_stmt = Database::prepare("
$json_result = HostingPlans::getLocal($userinfo, array( SELECT * FROM `" . TABLE_PANEL_PLANS . "` WHERE `id` = :id");
$result = Database::pexecute_first($result_stmt, array(
'id' => $id 'id' => $id
))->get(); ));
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
if ($result['id'] != 0 && $result['id'] == $id && (int) $userinfo['adminid'] == $result['adminid']) { if ($result['id'] != 0 && $result['id'] == $id && (int) $userinfo['adminid'] == $result['adminid']) {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { $del_stmt = Database::prepare("
HostingPlans::getLocal($userinfo, array( DELETE FROM `" . TABLE_PANEL_PLANS . "` WHERE `id` = :id");
Database::pexecute($del_stmt, array(
'id' => $id 'id' => $id
))->delete(); ));
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
\Froxlor\UI\Response::redirectTo($filename, array( $log->logAction(ADM_ACTION, LOG_INFO, "Plan '" . $result['name'] . "' has been deleted by '" . $userinfo['loginname'] . "'");
redirectTo($filename, array(
'page' => $page, 'page' => $page,
's' => $s 's' => $s
)); ));
} else { } else {
\Froxlor\UI\HTML::askYesNo('plan_reallydelete', $filename, array( ask_yesno('plan_reallydelete', $filename, array(
'id' => $id, 'id' => $id,
'page' => $page, 'page' => $page,
'action' => $action 'action' => $action
), $result['name']); ), $result['name']);
} }
} else { } else {
\Froxlor\UI\Response::standard_error('nopermissionsorinvalidid'); standard_error('nopermissionsorinvalidid');
} }
} elseif ($action == 'add') { } elseif ($action == 'add') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { $name = validate($_POST['name'], 'name');
HostingPlans::getLocal($userinfo, $_POST)->add(); $description = validate(str_replace("\r\n", "\n", $_POST['description']), 'description', '/^[^\0]*$/');
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage()); $value_arr = array();
$value_arr['diskspace'] = intval_ressource($_POST['diskspace']);
if (isset($_POST['diskspace_ul'])) {
$value_arr['diskspace'] = - 1;
} }
\Froxlor\UI\Response::redirectTo($filename, array(
$value_arr['traffic'] = doubleval_ressource($_POST['traffic']);
if (isset($_POST['traffic_ul'])) {
$value_arr['traffic'] = - 1;
}
$value_arr['subdomains'] = intval_ressource($_POST['subdomains']);
if (isset($_POST['subdomains_ul'])) {
$value_arr['subdomains'] = - 1;
}
$value_arr['emails'] = intval_ressource($_POST['emails']);
if (isset($_POST['emails_ul'])) {
$value_arr['emails'] = - 1;
}
$value_arr['email_accounts'] = intval_ressource($_POST['email_accounts']);
if (isset($_POST['email_accounts_ul'])) {
$value_arr['email_accounts'] = - 1;
}
$value_arr['email_forwarders'] = intval_ressource($_POST['email_forwarders']);
if (isset($_POST['email_forwarders_ul'])) {
$value_arr['email_forwarders'] = - 1;
}
if (Settings::Get('system.mail_quota_enabled') == '1') {
$value_arr['email_quota'] = validate($_POST['email_quota'], 'email_quota', '/^\d+$/', 'vmailquotawrong', array(
'0',
''
));
if (isset($_POST['email_quota_ul'])) {
$value_arr['email_quota'] = - 1;
}
} else {
$value_arr['email_quota'] = - 1;
}
$value_arr['email_imap'] = 0;
if (isset($_POST['email_imap'])) {
$value_arr['email_imap'] = intval_ressource($_POST['email_imap']);
}
$value_arr['email_pop3'] = 0;
if (isset($_POST['email_pop3'])) {
$value_arr['email_pop3'] = intval_ressource($_POST['email_pop3']);
}
$value_arr['ftps'] = intval_ressource($_POST['ftps']);
if (isset($_POST['ftps_ul'])) {
$value_arr['ftps'] = - 1;
}
$value_arr['tickets'] = (Settings::Get('ticket.enabled') == 1 ? intval_ressource($_POST['tickets']) : 0);
if (isset($_POST['tickets_ul']) && Settings::Get('ticket.enabled') == '1') {
$value_arr['tickets'] = - 1;
}
$value_arr['mysqls'] = intval_ressource($_POST['mysqls']);
if (isset($_POST['mysqls_ul'])) {
$value_arr['mysqls'] = - 1;
}
$value_arr['phpenabled'] = 0;
if (isset($_POST['phpenabled'])) {
$value_arr['phpenabled'] = intval($_POST['phpenabled']);
}
$value_arr['allowed_phpconfigs'] = array();
if (isset($_POST['allowed_phpconfigs']) && is_array($_POST['allowed_phpconfigs'])) {
foreach ($_POST['allowed_phpconfigs'] as $allowed_phpconfig) {
$allowed_phpconfig = intval($allowed_phpconfig);
$value_arr['allowed_phpconfigs'][] = $allowed_phpconfig;
}
}
$value_arr['perlenabled'] = 0;
if (isset($_POST['perlenabled'])) {
$value_arr['perlenabled'] = intval($_POST['perlenabled']);
}
$value_arr['dnsenabled'] = 0;
if (isset($_POST['dnsenabled'])) {
$value_arr['dnsenabled'] = intval($_POST['dnsenabled']);
}
$ins_stmt = Database::prepare("
INSERT INTO `" . TABLE_PANEL_PLANS . "`
SET `adminid` = :adminid, `name` = :name, `description` = :desc, `value` = :valuearr, `ts` = UNIX_TIMESTAMP();
");
$ins_data = array(
'adminid' => $userinfo['adminid'],
'name' => $name,
'desc' => $description,
'valuearr' => json_encode($value_arr)
);
Database::pexecute($ins_stmt, $ins_data);
$log->logAction(ADM_ACTION, LOG_WARNING, "added plan '" . $name . "'");
redirectTo($filename, array(
'page' => $page, 'page' => $page,
's' => $s 's' => $s
)); ));
} else { } else {
$diskspace_ul = \Froxlor\UI\HTML::makecheckbox('diskspace_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); $diskspace_ul = makecheckbox('diskspace_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$traffic_ul = \Froxlor\UI\HTML::makecheckbox('traffic_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); $traffic_ul = makecheckbox('traffic_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$subdomains_ul = \Froxlor\UI\HTML::makecheckbox('subdomains_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); $subdomains_ul = makecheckbox('subdomains_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$emails_ul = \Froxlor\UI\HTML::makecheckbox('emails_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); $emails_ul = makecheckbox('emails_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$email_accounts_ul = \Froxlor\UI\HTML::makecheckbox('email_accounts_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); $email_accounts_ul = makecheckbox('email_accounts_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$email_forwarders_ul = \Froxlor\UI\HTML::makecheckbox('email_forwarders_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); $email_forwarders_ul = makecheckbox('email_forwarders_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$email_quota_ul = \Froxlor\UI\HTML::makecheckbox('email_quota_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); $email_quota_ul = makecheckbox('email_quota_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$ftps_ul = \Froxlor\UI\HTML::makecheckbox('ftps_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); $ftps_ul = makecheckbox('ftps_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$mysqls_ul = \Froxlor\UI\HTML::makecheckbox('mysqls_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true); $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);
$phpconfigs = array(); $phpconfigs = array();
$configs = Database::query(" $configs = Database::query("
@@ -159,27 +257,24 @@ if ($page == '' || $page == 'overview') {
unset($cust_add_data['customer_add']['sections']['section_cpre']); unset($cust_add_data['customer_add']['sections']['section_cpre']);
// merge // merge
$plans_add_data['plans_add']['sections'] = array_merge($plans_add_data['plans_add']['sections'], $cust_add_data['customer_add']['sections']); $plans_add_data['plans_add']['sections'] = array_merge($plans_add_data['plans_add']['sections'], $cust_add_data['customer_add']['sections']);
$plans_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($plans_add_data); $plans_add_form = htmlform::genHTMLForm($plans_add_data);
$title = $plans_add_data['plans_add']['title']; $title = $plans_add_data['plans_add']['title'];
$image = $plans_add_data['plans_add']['image']; $image = $plans_add_data['plans_add']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate("plans/plans_add") . "\";"); eval("echo \"" . getTemplate("plans/plans_add") . "\";");
} }
} elseif ($action == 'edit' && $id != 0) { } elseif ($action == 'edit' && $id != 0) {
try { $result_stmt = Database::prepare("
$json_result = HostingPlans::getLocal($userinfo, array( SELECT * FROM `" . TABLE_PANEL_PLANS . "` WHERE `id` = :id");
$result = Database::pexecute_first($result_stmt, array(
'id' => $id 'id' => $id
))->get(); ));
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
if ($result['name'] != '') { if ($result['name'] != '') {
$result['value'] = json_decode($result['value'], true); $result['value'] = json_decode($result['value'], true);
$result = \Froxlor\PhpHelper::htmlentitiesArray($result); $result = htmlentities_array($result);
foreach ($result['value'] as $index => $value) { foreach ($result['value'] as $index => $value) {
$result[$index] = $value; $result[$index] = $value;
@@ -188,58 +283,167 @@ if ($page == '' || $page == 'overview') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { $name = validate($_POST['name'], 'name');
HostingPlans::getLocal($userinfo, $_POST)->update(); $description = validate(str_replace("\r\n", "\n", $_POST['description']), 'description', '/^[^\0]*$/');
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage()); $value_arr = array();
$value_arr['diskspace'] = intval_ressource($_POST['diskspace']);
if (isset($_POST['diskspace_ul'])) {
$value_arr['diskspace'] = - 1;
} }
\Froxlor\UI\Response::redirectTo($filename, array(
$value_arr['traffic'] = doubleval_ressource($_POST['traffic']);
if (isset($_POST['traffic_ul'])) {
$value_arr['traffic'] = - 1;
}
$value_arr['subdomains'] = intval_ressource($_POST['subdomains']);
if (isset($_POST['subdomains_ul'])) {
$value_arr['subdomains'] = - 1;
}
$value_arr['emails'] = intval_ressource($_POST['emails']);
if (isset($_POST['emails_ul'])) {
$value_arr['emails'] = - 1;
}
$value_arr['email_accounts'] = intval_ressource($_POST['email_accounts']);
if (isset($_POST['email_accounts_ul'])) {
$value_arr['email_accounts'] = - 1;
}
$value_arr['email_forwarders'] = intval_ressource($_POST['email_forwarders']);
if (isset($_POST['email_forwarders_ul'])) {
$value_arr['email_forwarders'] = - 1;
}
if (Settings::Get('system.mail_quota_enabled') == '1') {
$value_arr['email_quota'] = validate($_POST['email_quota'], 'email_quota', '/^\d+$/', 'vmailquotawrong', array(
'0',
''
));
if (isset($_POST['email_quota_ul'])) {
$value_arr['email_quota'] = - 1;
}
} else {
$value_arr['email_quota'] = - 1;
}
$value_arr['email_imap'] = 0;
if (isset($_POST['email_imap'])) {
$value_arr['email_imap'] = intval_ressource($_POST['email_imap']);
}
$value_arr['email_pop3'] = 0;
if (isset($_POST['email_pop3'])) {
$value_arr['email_pop3'] = intval_ressource($_POST['email_pop3']);
}
$value_arr['ftps'] = intval_ressource($_POST['ftps']);
if (isset($_POST['ftps_ul'])) {
$value_arr['ftps'] = - 1;
}
$value_arr['tickets'] = (Settings::Get('ticket.enabled') == 1 ? intval_ressource($_POST['tickets']) : 0);
if (isset($_POST['tickets_ul']) && Settings::Get('ticket.enabled') == '1') {
$value_arr['tickets'] = - 1;
}
$value_arr['mysqls'] = intval_ressource($_POST['mysqls']);
if (isset($_POST['mysqls_ul'])) {
$value_arr['mysqls'] = - 1;
}
$value_arr['phpenabled'] = 0;
if (isset($_POST['phpenabled'])) {
$value_arr['phpenabled'] = intval($_POST['phpenabled']);
}
$value_arr['allowed_phpconfigs'] = array();
if (isset($_POST['allowed_phpconfigs']) && is_array($_POST['allowed_phpconfigs'])) {
foreach ($_POST['allowed_phpconfigs'] as $allowed_phpconfig) {
$allowed_phpconfig = intval($allowed_phpconfig);
$value_arr['allowed_phpconfigs'][] = $allowed_phpconfig;
}
}
$value_arr['perlenabled'] = 0;
if (isset($_POST['perlenabled'])) {
$value_arr['perlenabled'] = intval($_POST['perlenabled']);
}
$value_arr['dnsenabled'] = 0;
if (isset($_POST['dnsenabled'])) {
$value_arr['dnsenabled'] = intval($_POST['dnsenabled']);
}
$ins_stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_PLANS . "`
SET `name` = :name, `description` = :desc, `value` = :valuearr, `ts` = UNIX_TIMESTAMP()
WHERE `id` = :id
");
$ins_data = array(
'name' => $name,
'desc' => $description,
'valuearr' => json_encode($value_arr),
'id' => $id
);
Database::pexecute($ins_stmt, $ins_data);
$log->logAction(ADM_ACTION, LOG_WARNING, "updated plan '" . $name . "'");
redirectTo($filename, array(
'page' => $page, 'page' => $page,
's' => $s 's' => $s
)); ));
} else { } else {
$diskspace_ul = \Froxlor\UI\HTML::makecheckbox('diskspace_ul', $lng['customer']['unlimited'], '-1', false, $result['diskspace'], true, true); $diskspace_ul = makecheckbox('diskspace_ul', $lng['customer']['unlimited'], '-1', false, $result['diskspace'], true, true);
if ($result['diskspace'] == '-1') { if ($result['diskspace'] == '-1') {
$result['diskspace'] = ''; $result['diskspace'] = '';
} }
$traffic_ul = \Froxlor\UI\HTML::makecheckbox('traffic_ul', $lng['customer']['unlimited'], '-1', false, $result['traffic'], true, true); $traffic_ul = makecheckbox('traffic_ul', $lng['customer']['unlimited'], '-1', false, $result['traffic'], true, true);
if ($result['traffic'] == '-1') { if ($result['traffic'] == '-1') {
$result['traffic'] = ''; $result['traffic'] = '';
} }
$subdomains_ul = \Froxlor\UI\HTML::makecheckbox('subdomains_ul', $lng['customer']['unlimited'], '-1', false, $result['subdomains'], true, true); $subdomains_ul = makecheckbox('subdomains_ul', $lng['customer']['unlimited'], '-1', false, $result['subdomains'], true, true);
if ($result['subdomains'] == '-1') { if ($result['subdomains'] == '-1') {
$result['subdomains'] = ''; $result['subdomains'] = '';
} }
$emails_ul = \Froxlor\UI\HTML::makecheckbox('emails_ul', $lng['customer']['unlimited'], '-1', false, $result['emails'], true, true); $emails_ul = makecheckbox('emails_ul', $lng['customer']['unlimited'], '-1', false, $result['emails'], true, true);
if ($result['emails'] == '-1') { if ($result['emails'] == '-1') {
$result['emails'] = ''; $result['emails'] = '';
} }
$email_accounts_ul = \Froxlor\UI\HTML::makecheckbox('email_accounts_ul', $lng['customer']['unlimited'], '-1', false, $result['email_accounts'], true, true); $email_accounts_ul = makecheckbox('email_accounts_ul', $lng['customer']['unlimited'], '-1', false, $result['email_accounts'], true, true);
if ($result['email_accounts'] == '-1') { if ($result['email_accounts'] == '-1') {
$result['email_accounts'] = ''; $result['email_accounts'] = '';
} }
$email_forwarders_ul = \Froxlor\UI\HTML::makecheckbox('email_forwarders_ul', $lng['customer']['unlimited'], '-1', false, $result['email_forwarders'], true, true); $email_forwarders_ul = makecheckbox('email_forwarders_ul', $lng['customer']['unlimited'], '-1', false, $result['email_forwarders'], true, true);
if ($result['email_forwarders'] == '-1') { if ($result['email_forwarders'] == '-1') {
$result['email_forwarders'] = ''; $result['email_forwarders'] = '';
} }
$email_quota_ul = \Froxlor\UI\HTML::makecheckbox('email_quota_ul', $lng['customer']['unlimited'], '-1', false, $result['email_quota'], true, true); $email_quota_ul = makecheckbox('email_quota_ul', $lng['customer']['unlimited'], '-1', false, $result['email_quota'], true, true);
if ($result['email_quota'] == '-1') { if ($result['email_quota'] == '-1') {
$result['email_quota'] = ''; $result['email_quota'] = '';
} }
$ftps_ul = \Froxlor\UI\HTML::makecheckbox('ftps_ul', $lng['customer']['unlimited'], '-1', false, $result['ftps'], true, true); $ftps_ul = makecheckbox('ftps_ul', $lng['customer']['unlimited'], '-1', false, $result['ftps'], true, true);
if ($result['ftps'] == '-1') { if ($result['ftps'] == '-1') {
$result['ftps'] = ''; $result['ftps'] = '';
} }
$mysqls_ul = \Froxlor\UI\HTML::makecheckbox('mysqls_ul', $lng['customer']['unlimited'], '-1', false, $result['mysqls'], true, true); $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') { if ($result['mysqls'] == '-1') {
$result['mysqls'] = ''; $result['mysqls'] = '';
} }
@@ -285,7 +489,6 @@ if ($page == '' || $page == 'overview') {
$result['customernumber'] = null; $result['customernumber'] = null;
$result['custom_notes'] = null; $result['custom_notes'] = null;
$result['custom_notes_show'] = null; $result['custom_notes_show'] = null;
$result['api_allowed'] = null;
$hosting_plans = null; $hosting_plans = null;
$admin_select_cnt = null; $admin_select_cnt = null;
$admin_select = null; $admin_select = null;
@@ -298,25 +501,22 @@ if ($page == '' || $page == 'overview') {
unset($cust_edit_data['customer_edit']['sections']['section_cpre']); unset($cust_edit_data['customer_edit']['sections']['section_cpre']);
// merge // merge
$plans_edit_data['plans_edit']['sections'] = array_merge($plans_edit_data['plans_edit']['sections'], $cust_edit_data['customer_edit']['sections']); $plans_edit_data['plans_edit']['sections'] = array_merge($plans_edit_data['plans_edit']['sections'], $cust_edit_data['customer_edit']['sections']);
$plans_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($plans_edit_data); $plans_edit_form = htmlform::genHTMLForm($plans_edit_data);
$title = $plans_edit_data['plans_edit']['title']; $title = $plans_edit_data['plans_edit']['title'];
$image = $plans_edit_data['plans_edit']['image']; $image = $plans_edit_data['plans_edit']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate("plans/plans_edit") . "\";"); eval("echo \"" . getTemplate("plans/plans_edit") . "\";");
} }
} }
} elseif ($action == 'jqGetPlanValues') { } elseif ($action == 'jqGetPlanValues') {
$planid = isset($_POST['planid']) ? (int)$_POST['planid'] : 0; $planid = isset($_POST['planid']) ? (int)$_POST['planid'] : 0;
try { $result_stmt = Database::prepare("
$json_result = HostingPlans::getLocal($userinfo, array( SELECT * FROM `" . TABLE_PANEL_PLANS . "` WHERE `id` = :id");
$result = Database::pexecute_first($result_stmt, array(
'id' => $planid 'id' => $planid
))->get(); ));
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
echo $result['value']; echo $result['value'];
exit(); exit;
} }
} }

View File

@@ -16,9 +16,6 @@
* @package Panel * @package Panel
* *
*/ */
use Froxlor\Database\Database;
use Froxlor\Settings;
use Froxlor\Api\Commands\Froxlor;
define('AREA', 'admin'); define('AREA', 'admin');
require './lib/init.php'; require './lib/init.php';
@@ -30,10 +27,12 @@ $sql_root = Database::getSqlData();
Database::needRoot(false); Database::needRoot(false);
if ($page == 'overview' && $userinfo['change_serversettings'] == '1') { if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
$settings_data = \Froxlor\PhpHelper::loadConfigArrayDir('./actions/admin/settings/'); $settings_data = loadConfigArrayDir('./actions/admin/settings/');
Settings::loadSettingsInto($settings_data); $settings = loadSettings($settings_data);
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send'])
&& $_POST['send'] == 'send'
) {
$_part = isset($_GET['part']) ? $_GET['part'] : ''; $_part = isset($_GET['part']) ? $_GET['part'] : '';
if ($_part == '') { if ($_part == '') {
@@ -49,6 +48,7 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
$settings_part = true; $settings_part = true;
} }
$only_enabledisable = false; $only_enabledisable = false;
} else { } else {
$settings_all = false; $settings_all = false;
$settings_part = false; $settings_part = false;
@@ -56,28 +56,30 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
} }
// check if the session timeout is too low #815 // check if the session timeout is too low #815
if (isset($_POST['session_sessiontimeout']) && $_POST['session_sessiontimeout'] < 60) { if (isset($_POST['session_sessiontimeout'])
\Froxlor\UI\Response::standard_error($lng['error']['session_timeout'], $lng['error']['session_timeout_desc']); && $_POST['session_sessiontimeout'] < 60
) {
standard_error($lng['error']['session_timeout'], $lng['error']['session_timeout_desc']);
} }
if (\Froxlor\UI\Form::processFormEx($settings_data, $_POST, array( if (processFormEx(
'filename' => $filename, $settings_data,
'action' => $action, $_POST,
'page' => $page array('filename' => $filename, 'action' => $action, 'page' => $page),
), $_part, $settings_all, $settings_part, $only_enabledisable)) { $_part,
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "rebuild configfiles due to changed setting"); $settings_all,
\Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::REBUILD_VHOST); $settings_part,
$only_enabledisable
)
) {
$log->logAction(ADM_ACTION, LOG_INFO, "rebuild configfiles due to changed setting");
inserttask('1');
// Using nameserver, insert a task which rebuilds the server config // Using nameserver, insert a task which rebuilds the server config
\Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::REBUILD_DNS); inserttask('4');
// cron.d file
\Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::REBUILD_CRON);
\Froxlor\UI\Response::standard_success('settingssaved', '', array( standard_success('settingssaved', '', array('filename' => $filename, 'action' => $action, 'page' => $page));
'filename' => $filename,
'action' => $action,
'page' => $page
));
} }
} else { } else {
$_part = isset($_GET['part']) ? $_GET['part'] : ''; $_part = isset($_GET['part']) ? $_GET['part'] : '';
@@ -85,36 +87,39 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
$_part = isset($_POST['part']) ? $_POST['part'] : ''; $_part = isset($_POST['part']) ? $_POST['part'] : '';
} }
$fields = \Froxlor\UI\Form::buildFormEx($settings_data, $_part); $fields = buildFormEx($settings_data, $_part);
$settings_page = ''; $settings_page = '';
if ($_part == '') { if ($_part == '') {
eval("\$settings_page .= \"" . \Froxlor\UI\Template::getTemplate("settings/settings_overview") . "\";"); eval("\$settings_page .= \"" . getTemplate("settings/settings_overview") . "\";");
} else { } else {
eval("\$settings_page .= \"" . \Froxlor\UI\Template::getTemplate("settings/settings") . "\";"); eval("\$settings_page .= \"" . getTemplate("settings/settings") . "\";");
} }
eval("echo \"" . \Froxlor\UI\Template::getTemplate("settings/settings_form_begin") . "\";"); eval("echo \"" . getTemplate("settings/settings_form_begin") . "\";");
eval("echo \$settings_page;"); eval("echo \$settings_page;");
eval("echo \"" . \Froxlor\UI\Template::getTemplate("settings/settings_form_end") . "\";"); eval("echo \"" . getTemplate("settings/settings_form_end") . "\";");
} }
} elseif ($page == 'phpinfo' && $userinfo['change_serversettings'] == '1') {
} elseif($page == 'phpinfo'
&& $userinfo['change_serversettings'] == '1'
) {
ob_start(); ob_start();
phpinfo(); phpinfo();
$phpinfo = array( $phpinfo = array('phpinfo' => array());
'phpinfo' => array() if (preg_match_all(
); '#(?:<h2>(?:<a name=".*?">)?(.*?)(?:</a>)?</h2>)|(?:<tr(?: class=".*?")?><t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>)?)?</tr>)#s',
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)) { ob_get_clean(), $matches, PREG_SET_ORDER
)
) {
foreach ($matches as $match) { foreach ($matches as $match) {
$end = array_keys($phpinfo); $end = array_keys($phpinfo);
$end = end($end); $end = end($end);
if (strlen($match[1])) { if (strlen($match[1])) {
$phpinfo[$match[1]] = array(); $phpinfo[$match[1]] = array();
} elseif (isset($match[3])) { } elseif (isset($match[3])) {
$phpinfo[$end][$match[2]] = isset($match[4]) ? array( $phpinfo[$end][$match[2]] = isset($match[4]) ? array($match[3], $match[4]) : $match[3];
$match[3],
$match[4]
) : $match[3];
} else { } else {
$phpinfo[$end][] = $match[2]; $phpinfo[$end][] = $match[2];
} }
@@ -124,99 +129,114 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
$phpinfoentries = ""; $phpinfoentries = "";
foreach ($section as $key => $val) { foreach ($section as $key => $val) {
if (is_array($val)) { if (is_array($val)) {
eval("\$phpinfoentries .= \"" . \Froxlor\UI\Template::getTemplate("settings/phpinfo/phpinfo_3") . "\";"); eval("\$phpinfoentries .= \"" . getTemplate("settings/phpinfo/phpinfo_3") . "\";");
} elseif (is_string($key)) { } elseif (is_string($key)) {
eval("\$phpinfoentries .= \"" . \Froxlor\UI\Template::getTemplate("settings/phpinfo/phpinfo_2") . "\";"); eval("\$phpinfoentries .= \"" . getTemplate("settings/phpinfo/phpinfo_2") . "\";");
} else { } else {
eval("\$phpinfoentries .= \"" . \Froxlor\UI\Template::getTemplate("settings/phpinfo/phpinfo_1") . "\";"); eval("\$phpinfoentries .= \"" . getTemplate("settings/phpinfo/phpinfo_1") . "\";");
} }
} }
// first header -> show actual php version // first header -> show actual php version
if (strtolower($name) == "phpinfo") { if (strtolower($name) == "phpinfo") {
$name = "PHP ".PHP_VERSION; $name = "PHP ".PHP_VERSION;
} }
eval("\$phpinfohtml .= \"" . \Froxlor\UI\Template::getTemplate("settings/phpinfo/phpinfo_table") . "\";"); eval("\$phpinfohtml .= \"" . getTemplate("settings/phpinfo/phpinfo_table") . "\";");
} }
$phpinfo = $phpinfohtml; $phpinfo = $phpinfohtml;
} else { } else {
\Froxlor\UI\Response::standard_error($lng['error']['no_phpinfo']); standard_error($lng['error']['no_phpinfo']);
} }
eval("echo \"" . \Froxlor\UI\Template::getTemplate("settings/phpinfo") . "\";"); eval("echo \"" . getTemplate("settings/phpinfo") . "\";");
} elseif ($page == 'rebuildconfigs' && $userinfo['change_serversettings'] == '1') {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "rebuild configfiles"); } elseif($page == 'rebuildconfigs'
\Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::REBUILD_VHOST); && $userinfo['change_serversettings'] == '1'
\Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::CREATE_QUOTA); ) {
if (isset($_POST['send'])
&& $_POST['send'] == 'send'
) {
$log->logAction(ADM_ACTION, LOG_INFO, "rebuild configfiles");
inserttask('1');
inserttask('10');
// Using nameserver, insert a task which rebuilds the server config // Using nameserver, insert a task which rebuilds the server config
\Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::REBUILD_DNS); inserttask('4');
// cron.d file // cron.d file
\Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::REBUILD_CRON); inserttask('99');
standard_success('rebuildingconfigs', '', array('filename' => 'admin_index.php'));
\Froxlor\UI\Response::standard_success('rebuildingconfigs', '', array(
'filename' => 'admin_index.php'
));
} else { } else {
\Froxlor\UI\HTML::askYesNo('admin_configs_reallyrebuild', $filename, array( ask_yesno('admin_configs_reallyrebuild', $filename, array('page' => $page));
'page' => $page
));
} }
} elseif ($page == 'updatecounters' && $userinfo['change_serversettings'] == '1') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { } elseif($page == 'updatecounters'
&& $userinfo['change_serversettings'] == '1'
) {
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "updated resource-counters"); if (isset($_POST['send'])
$updatecounters = \Froxlor\User::updateCounters(true); && $_POST['send'] == 'send'
) {
$log->logAction(ADM_ACTION, LOG_INFO, "updated resource-counters");
$updatecounters = updateCounters(true);
$customers = ''; $customers = '';
foreach ($updatecounters['customers'] as $customerid => $customer) { foreach ($updatecounters['customers'] as $customerid => $customer) {
eval("\$customers.=\"" . \Froxlor\UI\Template::getTemplate("settings/updatecounters_row_customer") . "\";"); eval("\$customers.=\"" . getTemplate("settings/updatecounters_row_customer") . "\";");
} }
$admins = ''; $admins = '';
foreach ($updatecounters['admins'] as $adminid => $admin) { foreach ($updatecounters['admins'] as $adminid => $admin) {
eval("\$admins.=\"" . \Froxlor\UI\Template::getTemplate("settings/updatecounters_row_admin") . "\";"); eval("\$admins.=\"" . getTemplate("settings/updatecounters_row_admin") . "\";");
} }
eval("echo \"" . \Froxlor\UI\Template::getTemplate("settings/updatecounters") . "\";"); eval("echo \"" . getTemplate("settings/updatecounters") . "\";");
} else { } else {
\Froxlor\UI\HTML::askYesNo('admin_counters_reallyupdate', $filename, array( ask_yesno('admin_counters_reallyupdate', $filename, array('page' => $page));
'page' => $page
));
} }
} elseif ($page == 'wipecleartextmailpws' && $userinfo['change_serversettings'] == '1') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { } elseif ($page == 'wipecleartextmailpws'
&& $userinfo['change_serversettings'] == '1'
) {
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "wiped all cleartext mail passwords"); if (isset($_POST['send'])
&& $_POST['send'] == 'send'
) {
$log->logAction(ADM_ACTION, LOG_WARNING, "wiped all cleartext mail passwords");
Database::query("UPDATE `" . TABLE_MAIL_USERS . "` SET `password` = '';"); Database::query("UPDATE `" . TABLE_MAIL_USERS . "` SET `password` = '';");
Database::query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '0' WHERE `settinggroup` = 'system' AND `varname` = 'mailpwcleartext'"); Database::query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '0' WHERE `settinggroup` = 'system' AND `varname` = 'mailpwcleartext'");
\Froxlor\UI\Response::redirectTo($filename, array( redirectTo($filename, array('s' => $s));
's' => $s
));
} else { } else {
\Froxlor\UI\HTML::askYesNo('admin_cleartextmailpws_reallywipe', $filename, array( ask_yesno('admin_cleartextmailpws_reallywipe', $filename, array('page' => $page));
'page' => $page
));
} }
} elseif ($page == 'wipequotas' && $userinfo['change_serversettings'] == '1') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { } elseif($page == 'wipequotas'
&& $userinfo['change_serversettings'] == '1'
) {
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "wiped all mailquotas"); 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_MAIL_USERS . "` SET `quota` = '0';");
Database::query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `email_quota_used` = '0'"); Database::query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `email_quota_used` = '0'");
\Froxlor\UI\Response::redirectTo($filename, array( redirectTo($filename, array('s' => $s));
's' => $s
));
} else { } else {
\Froxlor\UI\HTML::askYesNo('admin_quotas_reallywipe', $filename, array( ask_yesno('admin_quotas_reallywipe', $filename, array('page' => $page));
'page' => $page
));
} }
} elseif ($page == 'enforcequotas' && $userinfo['change_serversettings'] == '1') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { } 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 . "`"); $result_stmt = Database::query("SELECT `quota`, `customerid` FROM `" . TABLE_MAIL_USERS . "`");
@@ -230,10 +250,7 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
while ($array = $result_stmt->fetch(PDO::FETCH_ASSOC)) { while ($array = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$difference = Settings::Get('system.mail_quota') - $array['quota']; $difference = Settings::Get('system.mail_quota') - $array['quota'];
Database::pexecute($upd_stmt, array( Database::pexecute($upd_stmt, array('diff' => $difference, 'customerid' => $customerid));
'diff' => $difference,
'customerid' => $customerid
));
} }
} }
@@ -241,29 +258,27 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
$upd_stmt = Database::prepare(" $upd_stmt = Database::prepare("
UPDATE `" . TABLE_MAIL_USERS . "` SET `quota` = :quota UPDATE `" . TABLE_MAIL_USERS . "` SET `quota` = :quota
"); ");
Database::pexecute($upd_stmt, array( Database::pexecute($upd_stmt, array('quota' => Settings::Get('system.mail_quota')));
'quota' => Settings::Get('system.mail_quota')
));
// Update the Customer, if the used quota is bigger than the allowed quota // Update the Customer, if the used quota is bigger than the allowed quota
Database::query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `email_quota` = `email_quota_used` WHERE `email_quota` < `email_quota_used`"); Database::query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `email_quota` = `email_quota_used` WHERE `email_quota` < `email_quota_used`");
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, 'enforcing mailquota to all customers: ' . Settings::Get('system.mail_quota') . ' MB'); $log->logAction(ADM_ACTION, LOG_WARNING, 'enforcing mailquota to all customers: ' . Settings::Get('system.mail_quota') . ' MB');
\Froxlor\UI\Response::redirectTo($filename, array( redirectTo($filename, array('s' => $s));
's' => $s
));
} else { } else {
\Froxlor\UI\HTML::askYesNo('admin_quotas_reallyenforce', $filename, array( ask_yesno('admin_quotas_reallyenforce', $filename, array('page' => $page));
'page' => $page
));
} }
} elseif ($page == 'integritycheck' && $userinfo['change_serversettings'] == '1') { } elseif ($page == 'integritycheck'
$integrity = new \Froxlor\Database\IntegrityCheck(); && $userinfo['change_serversettings'] == '1'
if (isset($_POST['send']) && $_POST['send'] == 'send') { ) {
$integrity = new IntegrityCheck();
if (isset($_POST['send'])
&& $_POST['send'] == 'send'
) {
$integrity->fixAll(); $integrity->fixAll();
} elseif (isset($_GET['action']) && $_GET['action'] == "fix") { } elseif(isset($_GET['action'])
\Froxlor\UI\HTML::askYesNo('admin_integritycheck_reallyfix', $filename, array( && $_GET['action'] == "fix") {
'page' => $page ask_yesno('admin_integritycheck_reallyfix', $filename, array('page' => $page));
));
} }
$integritycheck = ''; $integritycheck = '';
@@ -271,27 +286,28 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
$displayid = $id + 1; $displayid = $id + 1;
$result = $integrity->$check(); $result = $integrity->$check();
$checkdesc = $lng['integrity_check'][$check]; $checkdesc = $lng['integrity_check'][$check];
eval("\$integritycheck.=\"" . \Froxlor\UI\Template::getTemplate("settings/integritycheck_row") . "\";"); eval("\$integritycheck.=\"" . getTemplate("settings/integritycheck_row") . "\";");
} }
eval("echo \"" . \Froxlor\UI\Template::getTemplate("settings/integritycheck") . "\";"); eval("echo \"" . getTemplate("settings/integritycheck") . "\";");
} elseif ($page == 'importexport' && $userinfo['change_serversettings'] == '1') { }
elseif ($page == 'importexport' && $userinfo['change_serversettings'] == '1')
{
// check for json-stuff // check for json-stuff
if (! extension_loaded('json')) { if (! extension_loaded('json')) {
\Froxlor\UI\Response::standard_error('jsonextensionnotfound'); standard_error('jsonextensionnotfound');
} }
if (isset($_GET['action']) && $_GET['action'] == "export") { if (isset($_GET['action']) && $_GET['action'] == "export") {
// export // export
try { try {
$json_result = Froxlor::getLocal($userinfo)->exportSettings(); $json_export = SImExporter::export();
$json_export = json_decode($json_result, true)['data'];
} catch(Exception $e) { } catch(Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage()); dynamic_error($e->getMessage());
} }
header('Content-disposition: attachment; filename=Froxlor_settings-'.$version.'-'.$dbversion.'_'.date('d.m.Y').'.json'); header('Content-disposition: attachment; filename=Froxlor_settings-'.$version.'-'.$dbversion.'_'.date('d.m.Y').'.json');
header('Content-type: application/json'); header('Content-type: application/json');
echo $json_export; echo $json_export;
exit(); exit;
} elseif (isset($_GET['action']) && $_GET['action'] == "import") { } elseif (isset($_GET['action']) && $_GET['action'] == "import") {
// import // import
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
@@ -299,29 +315,34 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
if (isset($_FILES["import_file"]["tmp_name"])) { if (isset($_FILES["import_file"]["tmp_name"])) {
$imp_content = file_get_contents($_FILES["import_file"]["tmp_name"]); $imp_content = file_get_contents($_FILES["import_file"]["tmp_name"]);
try { try {
Froxlor::getLocal($userinfo, array( SImExporter::import($imp_content);
'json_str' => $imp_content
))->importSettings();
} catch(Exception $e) { } catch(Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage()); dynamic_error($e->getMessage());
} }
\Froxlor\UI\Response::standard_success('settingsimported', '', array( inserttask('1');
'filename' => 'admin_settings.php' inserttask('10');
)); // Using nameserver, insert a task which rebuilds the server config
inserttask('4');
// cron.d file
inserttask('99');
standard_success('settingsimported', '', array('filename' => 'admin_settings.php'));
} }
\Froxlor\UI\Response::dynamic_error("Upload failed"); dynamic_error("Upload failed");
} }
} else { } else {
eval("echo \"" . \Froxlor\UI\Template::getTemplate("settings/importexport/index") . "\";"); eval("echo \"" . getTemplate("settings/importexport/index") . "\";");
} }
} elseif ($page == 'testmail') { }
if (isset($_POST['send']) && $_POST['send'] == 'send') { elseif ($page == 'testmail')
{
if (isset($_POST['send']) && $_POST['send'] == 'send')
{
$test_addr = isset($_POST['test_addr']) ? $_POST['test_addr'] : null; $test_addr = isset($_POST['test_addr']) ? $_POST['test_addr'] : null;
/** /**
* Initialize the mailingsystem * Initialize the mailingsystem
*/ */
$testmail = new \PHPMailer\PHPMailer\PHPMailer(true); $testmail = new PHPMailer(true);
$testmail->CharSet = "UTF-8"; $testmail->CharSet = "UTF-8";
if (Settings::Get('system.mail_use_smtp')) { if (Settings::Get('system.mail_use_smtp')) {
@@ -339,7 +360,7 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
} }
$_mailerror = false; $_mailerror = false;
if (\PHPMailer\PHPMailer\PHPMailer::ValidateAddress(Settings::Get('panel.adminmail')) !== false) { if (PHPMailer::ValidateAddress(Settings::Get('panel.adminmail')) !== false) {
// set return-to address and custom sender-name, see #76 // set return-to address and custom sender-name, see #76
$testmail->SetFrom(Settings::Get('panel.adminmail'), Settings::Get('panel.adminmail_defname')); $testmail->SetFrom(Settings::Get('panel.adminmail'), Settings::Get('panel.adminmail_defname'));
if (Settings::Get('panel.adminmail_return') != '') { if (Settings::Get('panel.adminmail_return') != '') {
@@ -353,7 +374,7 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
$testmail->MsgHTML(str_replace("\n", "<br />", $mail_body)); $testmail->MsgHTML(str_replace("\n", "<br />", $mail_body));
$testmail->AddAddress($test_addr); $testmail->AddAddress($test_addr);
$testmail->Send(); $testmail->Send();
} catch (\PHPMailer\PHPMailer\Exception $e) { } catch(phpmailerException $e) {
$mailerr_msg = $e->errorMessage(); $mailerr_msg = $e->errorMessage();
$_mailerror = true; $_mailerror = true;
} catch (Exception $e) { } catch (Exception $e) {
@@ -364,10 +385,7 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
if (!$_mailerror) { if (!$_mailerror) {
// success // success
$mail->ClearAddresses(); $mail->ClearAddresses();
\Froxlor\UI\Response::standard_success('testmailsent', '', array( standard_success('testmailsent', '', array('filename' => 'admin_settings.php', 'page' => 'testmail'));
'filename' => 'admin_settings.php',
'page' => 'testmail'
));
} }
} else { } else {
// invalid sender e-mail // invalid sender e-mail
@@ -380,5 +398,5 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
$mail_smtp_host = Settings::Get('system.mail_smtp_host'); $mail_smtp_host = Settings::Get('system.mail_smtp_host');
$mail_smtp_port = Settings::Get('system.mail_smtp_port'); $mail_smtp_port = Settings::Get('system.mail_smtp_port');
eval("echo \"" . \Froxlor\UI\Template::getTemplate("settings/testmail") . "\";"); eval("echo \"" . getTemplate("settings/testmail") . "\";");
} }

View File

@@ -16,15 +16,14 @@
* @package Panel * @package Panel
* *
*/ */
define('AREA', 'admin'); define('AREA', 'admin');
require './lib/init.php'; require './lib/init.php';
use Froxlor\Database\Database;
use Froxlor\Settings;
if (isset($_POST['subjectid'])) { if (isset($_POST['subjectid'])) {
$subjectid = intval($_POST['subjectid']); $subjectid = intval($_POST['subjectid']);
$mailbodyid = intval($_POST['mailbodyid']); $mailbodyid = intval($_POST['mailbodyid']);
} elseif(isset($_GET['subjectid'])) { } elseif(isset($_GET['subjectid'])) {
$subjectid = intval($_GET['subjectid']); $subjectid = intval($_GET['subjectid']);
$mailbodyid = intval($_GET['mailbodyid']); $mailbodyid = intval($_GET['mailbodyid']);
@@ -32,6 +31,7 @@ if (isset($_POST['subjectid'])) {
if (isset($_POST['id'])) { if (isset($_POST['id'])) {
$id = intval($_POST['id']); $id = intval($_POST['id']);
} elseif(isset($_GET['id'])) { } elseif(isset($_GET['id'])) {
$id = intval($_GET['id']); $id = intval($_GET['id']);
} }
@@ -46,7 +46,20 @@ $available_templates = array(
// only show templates of features that are enabled #1191 // only show templates of features that are enabled #1191
if ((int)Settings::Get('system.report_enable') == 1) { if ((int)Settings::Get('system.report_enable') == 1) {
array_push($available_templates, 'trafficmaxpercent', 'diskmaxpercent'); array_push($available_templates,
'trafficmaxpercent',
'diskmaxpercent'
);
}
if ((int)Settings::Get('ticket.enabled') == 1) {
array_push($available_templates,
'new_ticket_by_customer',
'new_ticket_for_customer',
'new_ticket_by_staff',
'new_reply_ticket_by_customer',
'new_reply_ticket_by_staff'
);
} }
$file_templates = array( $file_templates = array(
@@ -55,7 +68,7 @@ $file_templates = array(
if ($action == '') { if ($action == '') {
//email templates //email templates
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_templates"); $log->logAction(ADM_ACTION, LOG_NOTICE, "viewed admin_templates");
if (Settings::Get('panel.sendalternativemail') == 1) { if (Settings::Get('panel.sendalternativemail') == 1) {
$available_templates[] = 'pop_success_alternative'; $available_templates[] = 'pop_success_alternative';
@@ -65,10 +78,9 @@ if ($action == '') {
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
SELECT `id`, `language`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "` SELECT `id`, `language`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `templategroup`='mails' WHERE `adminid` = :adminid AND `templategroup`='mails'
ORDER BY `language`, `varname`"); ORDER BY `language`, `varname`"
Database::pexecute($result_stmt, array( );
'adminid' => $userinfo['adminid'] Database::pexecute($result_stmt, array('adminid' => $userinfo['adminid']));
));
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$parts = array(); $parts = array();
@@ -82,7 +94,7 @@ if ($action == '') {
$subjectid = $email['subject']; $subjectid = $email['subject'];
$mailbodyid = $email['mailbody']; $mailbodyid = $email['mailbody'];
$template = $lng['admin']['templates'][$action]; $template = $lng['admin']['templates'][$action];
eval("\$templates.=\"" . \Froxlor\UI\Template::getTemplate("templates/templates_template") . "\";"); eval("\$templates.=\"" . getTemplate("templates/templates_template") . "\";");
} }
} }
@@ -93,11 +105,9 @@ if ($action == '') {
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
SELECT `varname` FROM `" . TABLE_PANEL_TEMPLATES . "` SELECT `varname` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `language`= :lang WHERE `adminid` = :adminid AND `language`= :lang
AND `templategroup` = 'mails' AND `varname` LIKE '%_subject'"); AND `templategroup` = 'mails' AND `varname` LIKE '%_subject'"
Database::pexecute($result_stmt, array( );
'adminid' => $userinfo['adminid'], Database::pexecute($result_stmt, array('adminid' => $userinfo['adminid'], 'lang' => $language_name));
'lang' => $language_name
));
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$templates_done[] = str_replace('_subject', '', $row['varname']); $templates_done[] = str_replace('_subject', '', $row['varname']);
@@ -113,110 +123,106 @@ if ($action == '') {
$filetemplateadd = false; $filetemplateadd = false;
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
SELECT `id`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "` SELECT `id`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `templategroup`='files'"); WHERE `adminid` = :adminid AND `templategroup`='files'"
Database::pexecute($result_stmt, array( );
'adminid' => $userinfo['adminid'] Database::pexecute($result_stmt, array('adminid' => $userinfo['adminid']));
));
if (Database::num_rows() != count($file_templates)) { if (Database::num_rows() != count($file_templates)) {
$filetemplateadd = true; $filetemplateadd = true;
} }
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
eval("\$filetemplates.=\"" . \Froxlor\UI\Template::getTemplate("templates/templates_filetemplate") . "\";"); eval("\$filetemplates.=\"" . getTemplate("templates/templates_filetemplate") . "\";");
} }
eval("echo \"" . \Froxlor\UI\Template::getTemplate("templates/templates") . "\";"); eval("echo \"" . getTemplate("templates/templates") . "\";");
} elseif ($action == 'delete' && $subjectid != 0 && $mailbodyid != 0) {
} elseif($action == 'delete'
&& $subjectid != 0
&& $mailbodyid != 0
) {
//email templates //email templates
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
SELECT `language`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "` SELECT `language`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `id` = :id"); WHERE `adminid` = :adminid AND `id` = :id"
Database::pexecute($result_stmt, array( );
'adminid' => $userinfo['adminid'], Database::pexecute($result_stmt, array('adminid' => $userinfo['adminid'], 'id' => $subjectid));
'id' => $subjectid
));
$result = $result_stmt->fetch(PDO::FETCH_ASSOC); $result = $result_stmt->fetch(PDO::FETCH_ASSOC);
if ($result['varname'] != '') { if ($result['varname'] != '') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send'])
&& $_POST['send'] == 'send'
) {
$del_stmt = Database::prepare(" $del_stmt = Database::prepare("
DELETE FROM `" . TABLE_PANEL_TEMPLATES . "` DELETE FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid WHERE `adminid` = :adminid
AND (`id` = :ida OR `id` = :idb)"); AND (`id` = :ida OR `id` = :idb)"
);
Database::pexecute($del_stmt, array( Database::pexecute($del_stmt, array(
'adminid' => $userinfo['adminid'], 'adminid' => $userinfo['adminid'],
'ida' => $subjectid, 'ida' => $subjectid,
'idb' => $mailbodyid 'idb' => $mailbodyid
)); ));
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "deleted template '" . $result['language'] . ' - ' . $lng['admin']['templates'][str_replace('_subject', '', $result['varname'])] . "'"); $log->logAction(ADM_ACTION, LOG_INFO, "deleted template '" . $result['language'] . ' - ' . $lng['admin']['templates'][str_replace('_subject', '', $result['varname'])] . "'");
\Froxlor\UI\Response::redirectTo($filename, array( redirectTo($filename, array('page' => $page, 's' => $s));
'page' => $page,
's' => $s
));
} else { } else {
\Froxlor\UI\HTML::askYesNo('admin_template_reallydelete', $filename, array( 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'])]);
'subjectid' => $subjectid,
'mailbodyid' => $mailbodyid,
'page' => $page,
'action' => $action
), $result['language'] . ' - ' . $lng['admin']['templates'][str_replace('_subject', '', $result['varname'])]);
} }
} }
} elseif ($action == 'deletef' && $id != 0) {
} elseif($action == 'deletef'
&& $id != 0
) {
//file templates //file templates
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
SELECT * FROM `" . TABLE_PANEL_TEMPLATES . "` SELECT * FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `id` = :id"); WHERE `adminid` = :adminid AND `id` = :id"
Database::pexecute($result_stmt, array( );
'adminid' => $userinfo['adminid'], Database::pexecute($result_stmt, array('adminid' => $userinfo['adminid'], 'id' => $id));
'id' => $id
));
if (Database::num_rows() > 0) { if (Database::num_rows() > 0) {
$row = $result_stmt->fetch(PDO::FETCH_ASSOC); $row = $result_stmt->fetch(PDO::FETCH_ASSOC);
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send'])
&& $_POST['send'] == 'send'
) {
$del_stmt = Database::prepare(" $del_stmt = Database::prepare("
DELETE FROM `" . TABLE_PANEL_TEMPLATES . "` DELETE FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `id` = :id"); WHERE `adminid` = :adminid AND `id` = :id"
Database::pexecute($del_stmt, array( );
'adminid' => $userinfo['adminid'], Database::pexecute($del_stmt, array('adminid' => $userinfo['adminid'], 'id' => $id));
'id' => $id $log->logAction(ADM_ACTION, LOG_INFO, "deleted template '" . $lng['admin']['templates'][$row['varname']] . "'");
)); redirectTo($filename, array('page' => $page, 's' => $s));
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "deleted template '" . $lng['admin']['templates'][$row['varname']] . "'");
\Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page,
's' => $s
));
} else { } else {
\Froxlor\UI\HTML::askYesNo('admin_template_reallydelete', $filename, array( 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 { } else {
\Froxlor\UI\Response::standard_error('templatenotfound'); standard_error('templatenotfound');
} }
} elseif($action == 'add') { } elseif($action == 'add') {
if (Settings::Get('panel.sendalternativemail') == 1) { if (Settings::Get('panel.sendalternativemail') == 1) {
$available_templates[] = 'pop_success_alternative'; $available_templates[] = 'pop_success_alternative';
} }
if (isset($_POST['prepare']) && $_POST['prepare'] == 'prepare') { if (isset($_POST['prepare'])
&& $_POST['prepare'] == 'prepare'
) {
//email templates //email templates
$language = htmlentities(\Froxlor\Validate\Validate::validate($_POST['language'], 'language', '/^[^\r\n\0"\']+$/', 'nolanguageselect')); $language = htmlentities(validate($_POST['language'], 'language', '/^[^\r\n\0"\']+$/', 'nolanguageselect'));
$template = \Froxlor\Validate\Validate::validate($_POST['template'], 'template'); $template = validate($_POST['template'], 'template');
$lng_bak = $lng; $lng_bak = $lng;
foreach ($langs['English'] as $key => $value) { foreach ($langs['English'] as $key => $value) {
include_once \Froxlor\FileDir::makeSecurePath($value['file']); include_once makeSecurePath($value['file']);
} }
if ($language != 'English') { if ($language != 'English') {
foreach ($langs[$language] as $key => $value) { foreach ($langs[$language] as $key => $value) {
include \Froxlor\FileDir::makeSecurePath($value['file']); include makeSecurePath($value['file']);
} }
} }
@@ -226,27 +232,28 @@ if ($action == '') {
$lng = $lng_bak; $lng = $lng_bak;
$template_add_data = include_once dirname(__FILE__).'/lib/formfields/admin/templates/formfield.template_add.php'; $template_add_data = include_once dirname(__FILE__).'/lib/formfields/admin/templates/formfield.template_add.php';
$template_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($template_add_data); $template_add_form = htmlform::genHTMLForm($template_add_data);
$title = $template_add_data['template_add']['title']; $title = $template_add_data['template_add']['title'];
$image = $template_add_data['template_add']['image']; $image = $template_add_data['template_add']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate("templates/templates_add_2") . "\";"); eval("echo \"" . getTemplate("templates/templates_add_2") . "\";");
} elseif (isset($_POST['send']) && $_POST['send'] == 'send') {
} elseif(isset($_POST['send'])
&& $_POST['send'] == 'send'
) {
//email templates //email templates
$language = htmlentities(\Froxlor\Validate\Validate::validate($_POST['language'], 'language', '/^[^\r\n\0"\']+$/', 'nolanguageselect')); $language = htmlentities(validate($_POST['language'], 'language', '/^[^\r\n\0"\']+$/', 'nolanguageselect'));
$template = \Froxlor\Validate\Validate::validate($_POST['template'], 'template'); $template = validate($_POST['template'], 'template');
$subject = \Froxlor\Validate\Validate::validate($_POST['subject'], 'subject', '/^[^\r\n\0]+$/', 'nosubjectcreate'); $subject = validate($_POST['subject'], 'subject', '/^[^\r\n\0]+$/', 'nosubjectcreate');
$mailbody = \Froxlor\Validate\Validate::validate($_POST['mailbody'], 'mailbody', '/^[^\0]+$/', 'nomailbodycreate'); $mailbody = validate($_POST['mailbody'], 'mailbody', '/^[^\0]+$/', 'nomailbodycreate');
$templates = array(); $templates = array();
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
SELECT `varname` FROM `" . TABLE_PANEL_TEMPLATES . "` SELECT `varname` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `language` = :lang WHERE `adminid` = :adminid AND `language` = :lang
AND `templategroup` = 'mails' AND `varname` LIKE '%_subject'"); AND `templategroup` = 'mails' AND `varname` LIKE '%_subject'"
Database::pexecute($result_stmt, array( );
'adminid' => $userinfo['adminid'], Database::pexecute($result_stmt, array('adminid' => $userinfo['adminid'], 'lang' => $language));
'lang' => $language
));
while($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { while($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$templates[] = str_replace('_subject', '', $row['varname']); $templates[] = str_replace('_subject', '', $row['varname']);
@@ -254,7 +261,8 @@ if ($action == '') {
$templates = array_diff($available_templates, $templates); $templates = array_diff($available_templates, $templates);
if (array_search($template, $templates) === false) { if (array_search($template, $templates) === false) {
\Froxlor\UI\Response::standard_error('templatenotfound'); standard_error('templatenotfound');
} else { } else {
$ins_stmt = Database::prepare(" $ins_stmt = Database::prepare("
INSERT INTO `" . TABLE_PANEL_TEMPLATES . "` SET INSERT INTO `" . TABLE_PANEL_TEMPLATES . "` SET
@@ -262,7 +270,8 @@ if ($action == '') {
`language` = :lang, `language` = :lang,
`templategroup` = 'mails', `templategroup` = 'mails',
`varname` = :var, `varname` = :var,
`value` = :value"); `value` = :value"
);
// mail-subject // mail-subject
$ins_data = array( $ins_data = array(
@@ -282,16 +291,16 @@ if ($action == '') {
); );
Database::pexecute($ins_stmt, $ins_data); Database::pexecute($ins_stmt, $ins_data);
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "added template '" . $language . ' - ' . $template . "'"); $log->logAction(ADM_ACTION, LOG_INFO, "added template '" . $language . ' - ' . $template . "'");
\Froxlor\UI\Response::redirectTo($filename, array( redirectTo($filename, array('page' => $page, 's' => $s));
'page' => $page,
's' => $s
));
} }
} elseif (isset($_POST['filesend']) && $_POST['filesend'] == 'filesend') {
} elseif(isset($_POST['filesend'])
&& $_POST['filesend'] == 'filesend'
) {
//file templates //file templates
$template = \Froxlor\Validate\Validate::validate($_POST['template'], 'template'); $template = validate($_POST['template'], 'template');
$filecontent = \Froxlor\Validate\Validate::validate($_POST['filecontent'], 'filecontent', '/^[^\0]+$/', 'filecontentnotset'); $filecontent = validate($_POST['filecontent'], 'filecontent', '/^[^\0]+$/', 'filecontentnotset');
$ins_stmt = Database::prepare(" $ins_stmt = Database::prepare("
INSERT INTO `" . TABLE_PANEL_TEMPLATES . "` SET INSERT INTO `" . TABLE_PANEL_TEMPLATES . "` SET
@@ -299,7 +308,8 @@ if ($action == '') {
`language` = '', `language` = '',
`templategroup` = 'files', `templategroup` = 'files',
`varname` = :var, `varname` = :var,
`value` = :value"); `value` = :value"
);
$ins_data = array( $ins_data = array(
'adminid' => $userinfo['adminid'], 'adminid' => $userinfo['adminid'],
@@ -308,11 +318,9 @@ if ($action == '') {
); );
Database::pexecute($ins_stmt, $ins_data); Database::pexecute($ins_stmt, $ins_data);
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "added template '" . $template . "'"); $log->logAction(ADM_ACTION, LOG_INFO, "added template '" . $template . "'");
\Froxlor\UI\Response::redirectTo($filename, array( redirectTo($filename, array('page' => $page, 's' => $s));
'page' => $page,
's' => $s
));
} elseif(!isset($_GET['files'])) { } elseif(!isset($_GET['files'])) {
//email templates //email templates
@@ -325,11 +333,9 @@ if ($action == '') {
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
SELECT `varname` FROM `" . TABLE_PANEL_TEMPLATES . "` SELECT `varname` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `language` = :lang WHERE `adminid` = :adminid AND `language` = :lang
AND `templategroup` = 'mails' AND `varname` LIKE '%_subject'"); AND `templategroup` = 'mails' AND `varname` LIKE '%_subject'"
Database::pexecute($result_stmt, array( );
'adminid' => $userinfo['adminid'], Database::pexecute($result_stmt, array('adminid' => $userinfo['adminid'], 'lang' => $language_name));
'lang' => $language_name
));
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$templates[] = str_replace('_subject', '', $row['varname']); $templates[] = str_replace('_subject', '', $row['varname']);
@@ -337,32 +343,33 @@ if ($action == '') {
if (count(array_diff($available_templates, $templates)) > 0) { if (count(array_diff($available_templates, $templates)) > 0) {
$add = true; $add = true;
$language_options .= \Froxlor\UI\HTML::makeoption($language_name, $language_file, $userinfo['language'], true, true); $language_options.= makeoption($language_name, $language_file, $userinfo['language'], true, true);
$templates = array_diff($available_templates, $templates); $templates = array_diff($available_templates, $templates);
foreach ($templates as $template) { foreach ($templates as $template) {
$template_options .= \Froxlor\UI\HTML::makeoption($lng['admin']['templates'][$template], $template, NULL, true, true, $language_file) . "\n"; $template_options.= makeoption($lng['admin']['templates'][$template], $template, NULL, true, true, $language_file) . "\n";
} }
} }
} }
if ($add) { if ($add) {
eval("echo \"" . \Froxlor\UI\Template::getTemplate("templates/templates_add_1") . "\";"); eval("echo \"" . getTemplate("templates/templates_add_1") . "\";");
} else { } else {
\Froxlor\UI\Response::standard_error('alltemplatesdefined'); standard_error('alltemplatesdefined');
} }
} else { } else {
//filetemplates //filetemplates
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
SELECT `id`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "` SELECT `id`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `templategroup`='files'"); WHERE `adminid` = :adminid AND `templategroup`='files'"
Database::pexecute($result_stmt, array( );
'adminid' => $userinfo['adminid'] Database::pexecute($result_stmt, array('adminid' => $userinfo['adminid']));
));
if (Database::num_rows() == count($file_templates)) { if (Database::num_rows() == count($file_templates)) {
\Froxlor\UI\Response::standard_error('alltemplatesdefined'); standard_error('alltemplatesdefined');
} else { } else {
$templatesdefined = array(); $templatesdefined = array();
@@ -373,39 +380,44 @@ if ($action == '') {
} }
foreach (array_diff($file_templates, $templatesdefined) as $template) { foreach (array_diff($file_templates, $templatesdefined) as $template) {
$free_templates .= \Froxlor\UI\HTML::makeoption($lng['admin']['templates'][$template], $template, '', true); $free_templates.= makeoption($lng['admin']['templates'][$template], $template, '', true);
} }
$filetemplate_add_data = include_once dirname(__FILE__).'/lib/formfields/admin/templates/formfield.filetemplate_add.php'; $filetemplate_add_data = include_once dirname(__FILE__).'/lib/formfields/admin/templates/formfield.filetemplate_add.php';
$filetemplate_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($filetemplate_add_data); $filetemplate_add_form = htmlform::genHTMLForm($filetemplate_add_data);
$title = $filetemplate_add_data['filetemplate_add']['title']; $title = $filetemplate_add_data['filetemplate_add']['title'];
$image = $filetemplate_add_data['filetemplate_add']['image']; $image = $filetemplate_add_data['filetemplate_add']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate("templates/filetemplates_add") . "\";"); eval("echo \"" . getTemplate("templates/filetemplates_add") . "\";");
} }
} }
} elseif ($action == 'edit' && $subjectid != 0 && $mailbodyid != 0) {
} elseif($action == 'edit'
&& $subjectid != 0
&& $mailbodyid != 0
) {
//email templates //email templates
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
SELECT `language`, `varname`, `value` FROM `" . TABLE_PANEL_TEMPLATES . "` SELECT `language`, `varname`, `value` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `id` = :subjectid"); WHERE `adminid` = :adminid AND `id` = :subjectid"
Database::pexecute($result_stmt, array( );
'adminid' => $userinfo['adminid'], Database::pexecute($result_stmt, array('adminid' => $userinfo['adminid'], 'subjectid' => $subjectid));
'subjectid' => $subjectid
));
$result = $result_stmt->fetch(PDO::FETCH_ASSOC); $result = $result_stmt->fetch(PDO::FETCH_ASSOC);
if ($result['varname'] != '') { if ($result['varname'] != '') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send'])
$subject = \Froxlor\Validate\Validate::validate($_POST['subject'], 'subject', '/^[^\r\n\0]+$/', 'nosubjectcreate'); && $_POST['send'] == 'send'
$mailbody = \Froxlor\Validate\Validate::validate($_POST['mailbody'], 'mailbody', '/^[^\0]+$/', 'nomailbodycreate'); ) {
$subject = validate($_POST['subject'], 'subject', '/^[^\r\n\0]+$/', 'nosubjectcreate');
$mailbody = validate($_POST['mailbody'], 'mailbody', '/^[^\0]+$/', 'nomailbodycreate');
$upd_stmt = Database::prepare(" $upd_stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_TEMPLATES . "` SET UPDATE `" . TABLE_PANEL_TEMPLATES . "` SET
`value` = :value `value` = :value
WHERE `adminid` = :adminid AND `id` = :id"); WHERE `adminid` = :adminid AND `id` = :id"
);
// subject // subject
Database::pexecute($upd_stmt, array( Database::pexecute($upd_stmt, array(
'value' => $subject, 'value' => $subject,
@@ -419,85 +431,85 @@ if ($action == '') {
'id' => $mailbodyid 'id' => $mailbodyid
)); ));
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "edited template '" . $result['varname'] . "'"); $log->logAction(ADM_ACTION, LOG_INFO, "edited template '" . $result['varname'] . "'");
\Froxlor\UI\Response::redirectTo($filename, array( redirectTo($filename, array('page' => $page, 's' => $s));
'page' => $page,
's' => $s
));
} else { } else {
$result = \Froxlor\PhpHelper::htmlentitiesArray($result); $result = htmlentities_array($result);
$template = $lng['admin']['templates'][str_replace('_subject', '', $result['varname'])]; $template = $lng['admin']['templates'][str_replace('_subject', '', $result['varname'])];
$subject = $result['value']; $subject = $result['value'];
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
SELECT `language`, `varname`, `value` SELECT `language`, `varname`, `value`
FROM `" . TABLE_PANEL_TEMPLATES . "` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `id` = :id"); WHERE `id` = :id"
Database::pexecute($result_stmt, array( );
'id' => $mailbodyid Database::pexecute($result_stmt, array('id' => $mailbodyid));
));
$result = $result_stmt->fetch(PDO::FETCH_ASSOC); $result = $result_stmt->fetch(PDO::FETCH_ASSOC);
$template_name = str_replace('_mailbody', '', $result['varname']); $template_name = str_replace('_mailbody', '', $result['varname']);
// don't escape the already escaped language-string so save up before htmlentities() // don't escape the already escaped language-string so save up before htmlentities()
$language = $result['language']; $language = $result['language'];
$result = \Froxlor\PhpHelper::htmlentitiesArray($result); $result = htmlentities_array($result);
$mailbody = $result['value']; $mailbody = $result['value'];
$template_edit_data = include_once dirname(__FILE__).'/lib/formfields/admin/templates/formfield.template_edit.php'; $template_edit_data = include_once dirname(__FILE__).'/lib/formfields/admin/templates/formfield.template_edit.php';
$template_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($template_edit_data); $template_edit_form = htmlform::genHTMLForm($template_edit_data);
$title = $template_edit_data['template_edit']['title']; $title = $template_edit_data['template_edit']['title'];
$image = $template_edit_data['template_edit']['image']; $image = $template_edit_data['template_edit']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate("templates/templates_edit") . "\";"); eval("echo \"" . getTemplate("templates/templates_edit") . "\";");
} }
} }
} elseif ($action == 'editf' && $id != 0) {
} elseif($action == 'editf'
&& $id != 0
) {
//file templates //file templates
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
SELECT * FROM `" . TABLE_PANEL_TEMPLATES . "` SELECT * FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `id` = :id"); WHERE `adminid` = :adminid AND `id` = :id"
Database::pexecute($result_stmt, array( );
'adminid' => $userinfo['adminid'], Database::pexecute($result_stmt, array('adminid' => $userinfo['adminid'], 'id' => $id));
'id' => $id
));
if(Database::num_rows() > 0) { if(Database::num_rows() > 0) {
$row = $result_stmt->fetch(PDO::FETCH_ASSOC); $row = $result_stmt->fetch(PDO::FETCH_ASSOC);
//filetemplates //filetemplates
if (isset($_POST['filesend']) && $_POST['filesend'] == 'filesend') { if (isset($_POST['filesend'])
$filecontent = \Froxlor\Validate\Validate::validate($_POST['filecontent'], 'filecontent', '/^[^\0]+$/', 'filecontentnotset'); && $_POST['filesend'] == 'filesend'
) {
$filecontent = validate($_POST['filecontent'], 'filecontent', '/^[^\0]+$/', 'filecontentnotset');
$upd_stmt = Database::prepare(" $upd_stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_TEMPLATES . "` SET UPDATE `" . TABLE_PANEL_TEMPLATES . "` SET
`value` = :value `value` = :value
WHERE `adminid` = :adminid AND `id` = :id"); WHERE `adminid` = :adminid AND `id` = :id"
);
Database::pexecute($upd_stmt, array( Database::pexecute($upd_stmt, array(
'value' => $filecontent, 'value' => $filecontent,
'adminid' => $userinfo['adminid'], 'adminid' => $userinfo['adminid'],
'id' => $id 'id' => $id
)); ));
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "edited template '" . $row['varname'] . "'"); $log->logAction(ADM_ACTION, LOG_INFO, "edited template '" . $row['varname'] . "'");
\Froxlor\UI\Response::redirectTo($filename, array( redirectTo($filename, array('page' => $page, 's' => $s));
'page' => $page,
's' => $s
));
} else { } else {
$row = \Froxlor\PhpHelper::htmlentitiesArray($row); $row = htmlentities_array($row);
$filetemplate_edit_data = include_once dirname(__FILE__).'/lib/formfields/admin/templates/formfield.filetemplate_edit.php'; $filetemplate_edit_data = include_once dirname(__FILE__).'/lib/formfields/admin/templates/formfield.filetemplate_edit.php';
$filetemplate_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($filetemplate_edit_data); $filetemplate_edit_form = htmlform::genHTMLForm($filetemplate_edit_data);
$title = $filetemplate_edit_data['filetemplate_edit']['title']; $title = $filetemplate_edit_data['filetemplate_edit']['title'];
$image = $filetemplate_edit_data['filetemplate_edit']['image']; $image = $filetemplate_edit_data['filetemplate_edit']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate("templates/filetemplates_edit") . "\";"); eval("echo \"" . getTemplate("templates/filetemplates_edit") . "\";");
} }
} else { } else {
\Froxlor\UI\Response::standard_error('templatenotfound'); standard_error('templatenotfound');
} }
} }

909
admin_tickets.php Normal file
View File

@@ -0,0 +1,909 @@
<?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
*
*/
define('AREA', 'admin');
require './lib/init.php';
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif(isset($_GET['id'])) {
$id = intval($_GET['id']);
// only check if this is not a category-id
if (!isset($_GET['page']) || (isset($_GET['page']) && $_GET['page'] != 'categories')) {
if (!$userinfo['customers_see_all']) {
/*
* Check if the current user is allowed to see the current ticket.
*/
$stmt = Database::prepare("
SELECT `id` FROM `panel_tickets`
WHERE `id` = :id AND `adminid` = :adminid
");
$result = Database::pexecute_first($stmt, array('id' => $id, 'adminid' => $userinfo['adminid']));
if ($result == null) {
// no rights to see the requested ticket
standard_error(array('ticketnotaccessible'));
}
}
}
}
if ($page == 'tickets'
&& $userinfo['customers'] != '0'
) {
// Let's see how many customers we have
$countcustomers_stmt = Database::prepare("
SELECT COUNT(`customerid`) as `countcustomers`
FROM `" . TABLE_PANEL_CUSTOMERS . "` " .
($userinfo['customers_see_all'] ? '' : "WHERE `adminid` = :adminid")
);
$countcustomers = Database::pexecute_first($countcustomers_stmt, array('adminid' => $userinfo['adminid']));
$countcustomers = (int)$countcustomers['countcustomers'];
if ($action == '') {
$log->logAction(ADM_ACTION, LOG_NOTICE, "viewed admin_tickets");
$fields = array(
'status' => $lng['ticket']['status'],
'lastchange' => $lng['ticket']['lastchange'],
'subject' => $lng['ticket']['subject'],
'lastreplier' => $lng['ticket']['lastreplier']
);
$paging = new paging($userinfo, TABLE_PANEL_TICKETS, $fields, null, null, 1, 'desc');
$result_stmt = Database::prepare("
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' " .
($userinfo['customers_see_all'] ? '' : " AND `adminid` = :adminid") .
$paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit()
);
Database::pexecute($result_stmt, array('adminid' => $userinfo['adminid']));
$num_rows = Database::num_rows();
$paging->setEntries($num_rows);
$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 = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
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_stmt = Database::prepare('
SELECT `customerid`, `firstname`, `name`, `company`, `loginname`
FROM `' . TABLE_PANEL_CUSTOMERS . '`
WHERE `customerid` = :cid'
);
$usr = Database::pexecute_first($usr_stmt, array('cid' => $cid));
if (isset($usr['loginname'])) {
$customer = getCorrectFullUserDetails($usr);
$customerloginname = $usr['loginname'];
$customerid = $usr['customerid'];
} else {
$customer = $lng['ticket']['nonexistingcustomer'];
}
eval("\$tickets.=\"" . getTemplate("tickets/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;
}
$row['subject'] = html_entity_decode($row['subject']);
if (strlen($row['subject']) > 30) {
$ts = wordwrap($row['subject'], 30, "|");
$ts = explode("|", $ts);
$row['subject'] = $ts[0]. '...';
}
eval("\$tickets.=\"" . getTemplate("tickets/tickets_tickets") . "\";");
$count++;
$_cid = $row['customerid'];
}
$i++;
}
}
eval("echo \"" . getTemplate("tickets/tickets") . "\";");
} elseif($action == 'new') {
if ($userinfo['tickets_used'] < $userinfo['tickets']
|| $userinfo['tickets'] == '-1'
) {
if (isset($_POST['send'])
&& $_POST['send'] == 'send'
) {
$newticket = ticket::getInstanceOf($userinfo, -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)$_POST['customer'], true, false);
$newticket->Set('message', validate(htmlentities(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 = '';
$where = '';
if ($userinfo['tickets_see_all'] != '1') {
$where = 'WHERE `adminid` = :adminid';
}
$result_stmt = Database::prepare('
SELECT `id`, `name` FROM `' . TABLE_PANEL_TICKET_CATS . '`
'.$where.' ORDER BY `logicalorder`, `name` ASC'
);
$result = Database::pexecute_first($result_stmt, array('adminid' => $userinfo['adminid']));
if (isset($result['name'])
&& $result['name'] != ''
) {
$result2_stmt = Database::prepare('
SELECT `id`, `name` FROM `' . TABLE_PANEL_TICKET_CATS . '`
'.$where.' ORDER BY `logicalorder`, `name` ASC'
);
Database::pexecute($result2_stmt, array('adminid' => $userinfo['adminid']));
while ($row = $result2_stmt->fetch(PDO::FETCH_ASSOC)) {
$categories.= makeoption($row['name'], $row['id']);
}
} else {
$categories = makeoption($lng['ticket']['no_cat'], '0');
}
$customers = '';
$result_customers_stmt = Database::prepare("
SELECT `customerid`, `loginname`, `name`, `firstname`, `company`
FROM `" . TABLE_PANEL_CUSTOMERS . "` " .
($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = :adminid")."
ORDER BY `name` ASC"
);
Database::pexecute($result_customers_stmt, array('adminid' => $userinfo['adminid']));
while ($row_customer = $result_customers_stmt->fetch(PDO::FETCH_ASSOC)) {
$customers.= makeoption(getCorrectFullUserDetails($row_customer) . ' (' . $row_customer['loginname'] . ')', $row_customer['customerid']);
}
$def_prio = Settings::Get('ticket.default_priority');
$priorities = makeoption($lng['ticket']['high'], '1', $def_prio);
$priorities.= makeoption($lng['ticket']['normal'], '2', $def_prio);
$priorities.= makeoption($lng['ticket']['low'], '3', $def_prio);
$ticket_new_data = include_once dirname(__FILE__).'/lib/formfields/admin/tickets/formfield.ticket_new.php';
$ticket_new_form = htmlform::genHTMLForm($ticket_new_data);
$title = $ticket_new_data['ticket_new']['title'];
$image = $ticket_new_data['ticket_new']['image'];
eval("echo \"" . getTemplate("tickets/tickets_new") . "\";");
}
} else {
standard_error('nomoreticketsavailable');
}
} elseif($action == 'answer'
&& $id != 0
) {
if (isset($_POST['send'])
&& $_POST['send'] == 'send'
) {
$replyticket = ticket::getInstanceOf($userinfo, -1);
$replyticket->Set('subject', validate($_POST['subject'], 'subject'), true, false);
$replyticket->Set('priority', validate($_POST['priority'], 'priority'), true, false);
$replyticket->Set('message', validate(htmlentities(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, (int)$id);
$replyticket->Set('customer', $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, (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 {
$cid = $mainticket->Get('customer');
$usr_stmt = Database::prepare('
SELECT `customerid`, `firstname`, `name`, `company`, `loginname`
FROM `' . TABLE_PANEL_CUSTOMERS . '`
WHERE `customerid` = :cid'
);
$usr = Database::pexecute_first($usr_stmt, array('cid' => $cid));
$by = '<a href="'.$linker->getLink(array('section' => 'customers', 'page' => 'customers', 'action' => 'su', 'id' => $cid)).'" rel="external">';
$by .= getCorrectFullUserDetails($usr).'</a>';
}
$subject = $mainticket->Get('subject');
$message = $mainticket->Get('message');
eval("\$ticket_replies.=\"" . getTemplate("tickets/tickets_tickets_main") . "\";");
$result_stmt = Database::prepare('
SELECT `name` FROM `' . TABLE_PANEL_TICKET_CATS . '` WHERE `id` = :cid'
);
$row = Database::pexecute_first($result_stmt, array('cid' => $mainticket->Get('category')));
$andere_stmt = Database::prepare('
SELECT * FROM `' . TABLE_PANEL_TICKETS . '`
WHERE `answerto` = :id ORDER BY `lastchange` ASC'
);
Database::pexecute($andere_stmt, array('id' => $id));
$numrows_andere = Database::num_rows();
while ($row2 = $andere_stmt->fetch(PDO::FETCH_ASSOC)) {
$subticket = ticket::getInstanceOf($userinfo, (int)$row2['id']);
$lastchange = date("d.m.Y H:i\h", $subticket->Get('lastchange'));
if ($subticket->Get('by') == '1') {
$by = $lng['ticket']['staff'];
} else {
$cid = $subticket->Get('customer');
$usr_stmt = Database::prepare('
SELECT `customerid`, `firstname`, `name`, `company`, `loginname`
FROM `' . TABLE_PANEL_CUSTOMERS . '`
WHERE `customerid` = :cid'
);
$usr = Database::pexecute_first($usr_stmt, array('cid' => $cid));
$by = '<a href="'.$linker->getLink(array('section' => 'customers', 'page' => 'customers', 'action' => 'su', 'id' => $cid)).'" rel="external">';
$by .= getCorrectFullUserDetails($usr).'</a>';
}
$subject = $subticket->Get('subject');
$message = $subticket->Get('message');
$row2 = htmlentities_array($row2);
eval("\$ticket_replies.=\"" . getTemplate("tickets/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 = htmlentities($mainticket->Get('subject'));
$ticket_replies_count = $numrows_andere + 1;
// don't forget the main-ticket!
$ticket_reply_data = include_once dirname(__FILE__).'/lib/formfields/admin/tickets/formfield.ticket_reply.php';
$ticket_reply_form = htmlform::genHTMLForm($ticket_reply_data);
$title = $ticket_reply_data['ticket_reply']['title'];
$image = $ticket_reply_data['ticket_reply']['image'];
eval("echo \"" . getTemplate("tickets/tickets_reply") . "\";");
}
} elseif($action == 'close'
&& $id != 0
) {
if (isset($_POST['send'])
&& $_POST['send'] == 'send'
) {
$now = time();
$mainticket = ticket::getInstanceOf($userinfo, (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, (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, (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, (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, (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, (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, (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'],
'logicalorder' => $lng['ticket']['logicalorder']
);
$where = '1'; // WHERE 1 is like no 'where-clause'
if ($userinfo['tickets_see_all'] != '1') {
$where = " `main`.`adminid` = :adminid";
}
$paging = new paging($userinfo, TABLE_PANEL_TICKET_CATS, $fields);
$result_stmt = Database::prepare("
SELECT `main`.`id`, `main`.`name`, `main`.`logicalorder`, (
SELECT COUNT(`sub`.`id`) FROM `" . TABLE_PANEL_TICKETS . "` `sub`
WHERE `sub`.`category` = `main`.`id`
AND `sub`.`answerto` = '0'
AND `sub`.`adminid` = :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` = :adminid
) as `ticketcountnotclosed`
FROM `" . TABLE_PANEL_TICKET_CATS . "` `main`
WHERE " . $where . $paging->getSqlWhere(true) . " " .
$paging->getSqlOrderBy() . " " . $paging->getSqlLimit()
);
Database::pexecute($result_stmt, array('adminid' => $userinfo['adminid']));
$numrows = Database::num_rows();
$paging->setEntries($numrows);
$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 = $numrows;
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
if ($paging->checkDisplay($i)) {
$row = htmlentities_array($row);
$closedtickets_count = ($row['ticketcount'] - $row['ticketcountnotclosed']);
eval("\$ticketcategories.=\"" . getTemplate("tickets/tickets_categories") . "\";");
$count++;
}
$i++;
}
eval("echo \"" . getTemplate("tickets/categories") . "\";");
} elseif($action == 'addcategory') {
if (isset($_POST['send'])
&& $_POST['send'] == 'send'
) {
$category = validate($_POST['category'], 'category');
$order = validate($_POST['logicalorder'], 'logicalorder');
if ($order < 1 || $order >= 1000) {
// use the latest available
$order = ticket::getHighestOrderNumber($userinfo['adminid']) + 1;
}
if ($category == '') {
standard_error(array('stringisempty', 'mycategory'));
} else {
ticket::addCategory($category, $userinfo['adminid'], $order);
$log->logAction(ADM_ACTION, LOG_INFO, "added ticket-category '" . $category . "'");
redirectTo($filename, array('page' => $page, 's' => $s));
}
} else {
$order = ticket::getHighestOrderNumber($userinfo['adminid']) + 1;
$category_new_data = include_once dirname(__FILE__).'/lib/formfields/admin/tickets/formfield.category_new.php';
$category_new_form = htmlform::genHTMLForm($category_new_data);
$title = $category_new_data['category_new']['title'];
$image = $category_new_data['category_new']['image'];
eval("echo \"" . getTemplate("tickets/tickets_newcategory") . "\";");
}
} elseif($action == 'editcategory'
&& $id != 0
) {
if (isset($_POST['send'])
&& $_POST['send'] == 'send'
) {
$category = validate($_POST['category'], 'category');
$order = validate($_POST['logicalorder'], 'logicalorder');
if ($order < 1 || $order >= 1000) {
$order = 1;
}
if ($category == '') {
standard_error(array('stringisempty', 'mycategory'));
} else {
ticket::editCategory($category, $id, $order);
$log->logAction(ADM_ACTION, LOG_INFO, "edited ticket-category '" . $category . "'");
redirectTo($filename, array('page' => $page, 's' => $s));
}
} else {
$row_stmt = Database::prepare('
SELECT * FROM `' . TABLE_PANEL_TICKET_CATS . '` WHERE `id` = :id'
);
$row = Database::pexecute_first($row_stmt, array('id' => $id));
$row = htmlentities_array($row);
$category_edit_data = include_once dirname(__FILE__).'/lib/formfields/admin/tickets/formfield.category_edit.php';
$category_edit_form = htmlform::genHTMLForm($category_edit_data);
$title = $category_edit_data['category_edit']['title'];
$image = $category_edit_data['category_edit']['image'];
eval("echo \"" . getTemplate("tickets/tickets_editcategory") . "\";");
}
} elseif($action == 'deletecategory'
&& $id != 0
) {
if (isset($_POST['send'])
&& $_POST['send'] == 'send'
) {
if (ticket::deleteCategory($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($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_stmt = Database::query('SELECT COUNT(`id`) as `ccount` FROM `' . TABLE_PANEL_TICKET_CATS . '`');
$cat = $cat_stmt->fetch(PDO::FETCH_ASSOC);
for ($x = 0;$x < $cat['ccount'];$x++) {
$categories[$x] = isset($_POST['category' . $x]) ? $_POST['category' . $x] : '';
}
$archive_search = ticket::getArchiveSearchStatement($subject, $priority, $fromdate, $todate, $message, $customer, $userinfo['adminid'], $categories);
$query = $archive_search[0];
$archive_params = $archive_search[1];
$fields = array(
'lastchange' => $lng['ticket']['lastchange'],
'subject' => $lng['ticket']['subject'],
'lastreplier' => $lng['ticket']['lastreplier']
);
$paging = new paging($userinfo, TABLE_PANEL_TICKETS, $fields);
$result_stmt = Database::prepare($query . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
Database::pexecute($result_stmt, $archive_params);
$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 = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
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 = -1;
foreach ($ticketrows as $ticket) {
if ($paging->checkDisplay($i)) {
$ticket['lastchange'] = date("d.m.y H:i", $ticket['lastchange']);
if ($_cid != $ticket['customerid']) {
$cid = $ticket['customerid'];
$usr_stmt = Database::prepare('
SELECT `customerid`, `firstname`, `name`, `company`, `loginname`
FROM `' . TABLE_PANEL_CUSTOMERS . '`
WHERE `customerid` = :cid'
);
$usr = Database::pexecute_first($usr_stmt, array('cid' => $cid));
if (isset($usr['loginname'])) {
$customer = getCorrectFullUserDetails($usr);
$customerloginname = $usr['loginname'];
$customerid = $usr['customerid'];
} else {
$customer = $lng['ticket']['nonexistingcustomer'];
$customerid = 0;
$customerloginname = '';
}
eval("\$tickets.=\"" . getTemplate("tickets/tickets_customer") . "\";");
}
$tickets_count++;
switch ($ticket['priority'])
{
case 1: $ticket['display'] = 'high';
break;
case 2: $ticket['display'] = 'normal';
break;
case 3: $ticket['display'] = 'low';
break;
default: $ticket['display'] = 'unknown';
}
$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) . '...';
}
$ticket = htmlentities_array($ticket);
eval("\$tickets.=\"" . getTemplate("tickets/archived_tickets") . "\";");
$count++;
$_cid = $ticket['customerid'];
}
}
$i++;
}
eval("echo \"" . getTemplate("tickets/archivesearch") . "\";");
} else {
$archived = array();
$archived = ticket::getLastArchived(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("tickets/archived_tickets") . "\";");
}
}
$priorities_options = makecheckbox('priority1', $lng['ticket']['high'], '1');
$priorities_options.= makecheckbox('priority2', $lng['ticket']['normal'], '2');
$priorities_options.= makecheckbox('priority3', $lng['ticket']['low'], '3');
$category_options = '';
$ccount = 0;
$result = Database::query('SELECT * FROM `' . TABLE_PANEL_TICKET_CATS . '` ORDER BY `name` ASC');
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$category_options.= makecheckbox('category' . $ccount, $row['name'], $row['id'], true);
$ccount++;
}
$customers = makeoption($lng['ticket']['nocustomer'], '-1', '-1');
$result_customers_stmt = Database::prepare("
SELECT `customerid`, `loginname`, `name`, `firstname`, `company`
FROM `" . TABLE_PANEL_CUSTOMERS . "` " .
($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = :adminid")."
ORDER BY `name` ASC"
);
Database::pexecute($result_customers_stmt, array('adminid' => $userinfo['adminid']));
while ($row_customer = $result_customers_stmt->fetch(PDO::FETCH_ASSOC)) {
$customers.= makeoption(getCorrectFullUserDetails($row_customer) . ' (' . $row_customer['loginname'] . ')', $row_customer['customerid']);
}
eval("echo \"" . getTemplate("tickets/archive") . "\";");
}
} elseif($action == 'view'
&& $id != 0
) {
$log->logAction(ADM_ACTION, LOG_NOTICE, "viewed archived-ticket #" . $id);
$ticket_replies = '';
$mainticket = ticket::getInstanceOf($userinfo, (int)$id);
$lastchange = date("d.m.Y H:i\h", $mainticket->Get('lastchange'));
$dt = date("d.m.Y H:i\h", $mainticket->Get('dt'));
$status = ticket::getStatusText($lng, $mainticket->Get('status'));
$isclosed = 1;
if ($mainticket->Get('by') == '1') {
$by = $lng['ticket']['staff'];
} else {
$cid = $mainticket->Get('customer');
$usr_stmt = Database::prepare('
SELECT `customerid`, `firstname`, `name`, `company`, `loginname`
FROM `' . TABLE_PANEL_CUSTOMERS . '`
WHERE `customerid` = :cid'
);
$usr = Database::pexecute_first($usr_stmt, array('cid' => $cid));
if (isset($usr['loginname'])) {
$customer = getCorrectFullUserDetails($usr);
$customerloginname = ' ('.$usr['loginname'].')';
$customerid = $usr['customerid'];
} else {
$customer = $lng['ticket']['nonexistingcustomer'];
$customerid = 0;
$customerloginname = '';
}
if ($customerid != 0) {
$by = '<a href="'.$linker->getLink(array('section' => 'customers', 'page' => 'customers', 'action' => 'su', 'id' => $customerid)).'" rel="external">';
$by .= $customer.$customerloginname.'</a>';
} else {
$by = $customer;
}
}
$subject = $mainticket->Get('subject');
$message = $mainticket->Get('message');
eval("\$ticket_replies.=\"" . getTemplate("tickets/tickets_tickets_main") . "\";");
$result_stmt = Database::prepare('
SELECT `name` FROM `' . TABLE_PANEL_TICKET_CATS . '` WHERE `id` = :cid'
);
$row = Database::pexecute_first($result_stmt, array('cid' => $mainticket->Get('category')));
$andere_stmt = Database::prepare('
SELECT * FROM `' . TABLE_PANEL_TICKETS . '` WHERE `answerto` = :id'
);
Database::pexecute($andere_stmt, array('id' => $id));
$numrows_andere = Database::num_rows();
while ($row2 = $andere_stmt->fetch(PDO::FETCH_ASSOC)) {
$subticket = ticket::getInstanceOf($userinfo, (int)$row2['id']);
$lastchange = date("d.m.Y H:i\h", $subticket->Get('lastchange'));
if ($subticket->Get('by') == '1') {
$by = $lng['ticket']['staff'];
} else {
$cid = $subticket->Get('customer');
$usr_stmt = Database::prepare('
SELECT `customerid`, `firstname`, `name`, `company`, `loginname`
FROM `' . TABLE_PANEL_CUSTOMERS . '`
WHERE `customerid` = :cid'
);
$usr = Database::pexecute_first($usr_stmt, array('cid' => $cid));
if (isset($usr['loginname'])) {
$customer = getCorrectFullUserDetails($usr);
$customerloginname = ' ('.$usr['loginname'].')';
$customerid = $usr['customerid'];
} else {
$customer = $lng['ticket']['nonexistingcustomer'];
$customerid = 0;
$customerloginname = '';
}
if ($customerid != 0) {
$by = '<a href="'.$linker->getLink(array('section' => 'customers', 'page' => 'customers', 'action' => 'su', 'id' => $customerid)).'" rel="external">';
$by .= $customer.$customerloginname.'</a>';
} else {
$by = $customer;
}
}
$subject = $subticket->Get('subject');
$message = $subticket->Get('message');
eval("\$ticket_replies.=\"" . getTemplate("tickets/tickets_tickets_list") . "\";");
}
$priorities = makeoption($lng['ticket']['high'], '1', htmlentities($mainticket->Get('priority')), true, true);
$priorities.= makeoption($lng['ticket']['normal'], '2', htmlentities($mainticket->Get('priority')), true, true);
$priorities.= makeoption($lng['ticket']['low'], '3', htmlentities($mainticket->Get('priority')), true, true);
$subject = $mainticket->Get('subject');
$ticket_replies_count = $numrows_andere + 1;
// don't forget the main-ticket!
eval("echo \"" . getTemplate("tickets/tickets_view") . "\";");
} elseif($action == 'delete'
&& $id != 0
) {
if (isset($_POST['send'])
&& $_POST['send'] == 'send'
) {
$mainticket = ticket::getInstanceOf($userinfo, (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, (int)$id);
ask_yesno('ticket_reallydelete', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $mainticket->Get('subject'));
}
}
} else {
standard_error('nocustomerforticket');
}

View File

@@ -15,11 +15,19 @@
* @package Panel * @package Panel
* *
*/ */
define('AREA', 'admin'); define('AREA', 'admin');
require './lib/init.php'; require './lib/init.php';
use Froxlor\Database\Database; if ($action == 'logout') {
use Froxlor\Settings; $logout_stmt = Database::prepare("
DELETE FROM `" . TABLE_PANEL_SESSIONS . "`
WHERE `userid` = :adminid
AND `adminsession` = '1'"
);
Database::pexecute($logout_stmt, array('adminid' => $userinfo['adminid']));
redirectTo('index.php');
}
if (isset($_POST['id'])) { if (isset($_POST['id'])) {
$id = intval($_POST['id']); $id = intval($_POST['id']);
@@ -40,7 +48,7 @@ $months = array(
'9' => 'sep', '9' => 'sep',
'10' => 'oct', '10' => 'oct',
'11' => 'nov', '11' => 'nov',
'12' => 'dec' '12' => 'dec',
); );
if ($page == 'overview' || $page == 'customers') { if ($page == 'overview' || $page == 'customers') {
@@ -56,26 +64,6 @@ if ($page == 'overview' || $page == 'customers') {
$maxyears = date("Y") - $minyear['year']; $maxyears = date("Y") - $minyear['year'];
} }
$params = [];
if ($userinfo['customers_see_all'] == '0') {
$params = [
'id' => $userinfo['adminid']
];
}
$customer_name_list_stmt = Database::prepare("
SELECT `customerid`,`company`,`name`,`firstname`
FROM `" . TABLE_PANEL_CUSTOMERS . "`
WHERE `deactivated`='0'" . ($userinfo['customers_see_all'] ? '' : " AND `adminid` = :id") . "
ORDER BY name"
);
$traffic_list_stmt = Database::prepare("
SELECT month, SUM(http+ftp_up+ftp_down+mail)*1024 AS traffic
FROM `" . TABLE_PANEL_TRAFFIC . "`
WHERE year = :year AND `customerid` = :id
GROUP BY month ORDER BY month"
);
for ($years = 0; $years<=$maxyears; $years++) { for ($years = 0; $years<=$maxyears; $years++) {
$overview['year'] = date("Y")-$years; $overview['year'] = date("Y")-$years;
@@ -93,10 +81,17 @@ if ($page == 'overview' || $page == 'customers') {
'sep' => 0, 'sep' => 0,
'oct' => 0, 'oct' => 0,
'nov' => 0, 'nov' => 0,
'dec' => 0 'dec' => 0,
); );
Database::pexecute($customer_name_list_stmt, $params); $customer_name_list_stmt = Database::prepare("
SELECT `customerid`,`company`,`name`,`firstname`
FROM `" . TABLE_PANEL_CUSTOMERS . "`
WHERE `deactivated`='0'" .
($userinfo['customers_see_all'] ? '' : " AND `adminid` = :id") . "
ORDER BY name"
);
Database::pexecute($customer_name_list_stmt, array('id' => $userinfo['adminid']));
while($customer_name = $customer_name_list_stmt->fetch(PDO::FETCH_ASSOC)) { while($customer_name = $customer_name_list_stmt->fetch(PDO::FETCH_ASSOC)) {
@@ -114,30 +109,33 @@ if ($page == 'overview' || $page == 'customers') {
'sep' => '-', 'sep' => '-',
'oct' => '-', 'oct' => '-',
'nov' => '-', 'nov' => '-',
'dec' => '-' 'dec' => '-',
); );
Database::pexecute($traffic_list_stmt, array( $traffic_list_stmt = Database::prepare("
'year' => (date("Y") - $years), SELECT month, SUM(http+ftp_up+ftp_down+mail)*1024 AS traffic
'id' => $customer_name['customerid'] FROM `" . TABLE_PANEL_TRAFFIC . "`
)); WHERE year = :year AND `customerid` = :id
GROUP BY month ORDER BY month"
);
Database::pexecute($traffic_list_stmt, array('year' => (date("Y")-$years), 'id' => $customer_name['customerid']));
while ($traffic_month = $traffic_list_stmt->fetch(PDO::FETCH_ASSOC)) { while ($traffic_month = $traffic_list_stmt->fetch(PDO::FETCH_ASSOC)) {
$virtual_host[$months[(int) $traffic_month['month']]] = \Froxlor\PhpHelper::sizeReadable($traffic_month['traffic'], 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s'); $virtual_host[$months[(int)$traffic_month['month']]] = size_readable($traffic_month['traffic'], 'GiB', 'bi', '%01.'.(int)Settings::Get('panel.decimal_places').'f %s');
$totals[$months[(int)$traffic_month['month']]] += $traffic_month['traffic']; $totals[$months[(int)$traffic_month['month']]] += $traffic_month['traffic'];
} }
eval("\$domain_list .= sprintf(\"%s\", \"" . \Froxlor\UI\Template::getTemplate("traffic/index_table_row") . "\");"); eval("\$domain_list .= sprintf(\"%s\", \"" . getTemplate("traffic/index_table_row") . "\");");
} }
// sum up totals // sum up totals
$virtual_host = array( $virtual_host = array(
'name' => $lng['traffic']['months']['total'] 'name' => $lng['traffic']['months']['total'],
); );
foreach ($totals as $month => $bytes) { foreach ($totals as $month => $bytes) {
$virtual_host[$month] = ($bytes == 0 ? '-' : \Froxlor\PhpHelper::sizeReadable($bytes, 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s')); $virtual_host[$month] = ($bytes == 0 ? '-' : size_readable($bytes, 'GiB', 'bi', '%01.'.(int)Settings::Get('panel.decimal_places').'f %s'));
} }
$customerview = 0; $customerview = 0;
eval("\$total_list = sprintf(\"%s\", \"" . \Froxlor\UI\Template::getTemplate("traffic/index_table_row") . "\");"); eval("\$total_list = sprintf(\"%s\", \"" . getTemplate("traffic/index_table_row") . "\");");
eval("\$stats_tables .= sprintf(\"%s\", \"" . \Froxlor\UI\Template::getTemplate("traffic/index_table") . "\");"); eval("\$stats_tables .= sprintf(\"%s\", \"" . getTemplate("traffic/index_table") . "\");");
} }
eval("echo \"" . \Froxlor\UI\Template::getTemplate("traffic/index") . "\";"); eval("echo \"" . getTemplate("traffic/index") . "\";");
} }

View File

@@ -14,25 +14,27 @@
* @package Panel * @package Panel
* *
*/ */
define('AREA', 'admin'); define('AREA', 'admin');
require './lib/init.php'; require './lib/init.php';
use Froxlor\Database\Database;
use Froxlor\Settings;
if ($page == 'overview') { if ($page == 'overview') {
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_updates"); $log->logAction(ADM_ACTION, LOG_NOTICE, "viewed admin_updates");
/** /**
* this is a dirty hack but syscp 1.4.2.1 does not * this is a dirty hack but syscp 1.4.2.1 does not
* have any version/dbversion in the database (don't know why) * have any version/dbversion in the database (don't know why)
* so we have to set them both to run a correct upgrade * so we have to set them both to run a correct upgrade
*/ */
if (! \Froxlor\Froxlor::isFroxlor()) { if (!isFroxlor()) {
if (Settings::Get('panel.version') == null || Settings::Get('panel.version') == '') { if (Settings::Get('panel.version') == null
|| Settings::Get('panel.version') == ''
) {
Settings::Set('panel.version', '1.4.2.1'); Settings::Set('panel.version', '1.4.2.1');
} }
if (Settings::Get('system.dbversion') == null || Settings::Get('system.dbversion') == '') { if (Settings::Get('system.dbversion') == null
|| Settings::Get('system.dbversion') == ''
) {
/** /**
* for syscp-stable (1.4.2.1) this value has to be 0 * for syscp-stable (1.4.2.1) this value has to be 0
* so the required table-fields are added correctly * so the required table-fields are added correctly
@@ -40,7 +42,8 @@ if ($page == 'overview') {
* -> bug #54 * -> bug #54
*/ */
$result_stmt = Database::query(" $result_stmt = Database::query("
SELECT `value` FROM `" . TABLE_PANEL_SETTINGS . "` WHERE `varname` = 'dbversion'"); SELECT `value` FROM `" . TABLE_PANEL_SETTINGS . "` WHERE `varname` = 'dbversion'"
);
$result = $result_stmt->fetch(PDO::FETCH_ASSOC); $result = $result_stmt->fetch(PDO::FETCH_ASSOC);
if (isset($result['value'])) { if (isset($result['value'])) {
@@ -51,22 +54,28 @@ if ($page == 'overview') {
} }
} }
if (\Froxlor\Froxlor::hasDbUpdates() || \Froxlor\Froxlor::hasUpdates()) { if (hasDbUpdates($dbversion) || hasUpdates($version)) {
$successful_update = false; $successful_update = false;
$message = ''; $message = '';
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send'])
if ((isset($_POST['update_preconfig']) && isset($_POST['update_changesagreed']) && intval($_POST['update_changesagreed']) != 0) || ! isset($_POST['update_preconfig'])) { && $_POST['send'] == 'send'
eval("echo \"" . \Froxlor\UI\Template::getTemplate('update/update_start') . "\";"); ) {
if ((isset($_POST['update_preconfig'])
&& isset($_POST['update_changesagreed'])
&& intval($_POST['update_changesagreed']) != 0)
|| !isset($_POST['update_preconfig'])
) {
eval("echo \"" . getTemplate('update/update_start') . "\";");
include_once \Froxlor\Froxlor::getInstallDir() . 'install/updatesql.php'; include_once './install/updatesql.php';
$redirect_url = 'admin_index.php?s=' . $s; $redirect_url = 'admin_index.php?s=' . $s;
eval("echo \"" . \Froxlor\UI\Template::getTemplate('update/update_end') . "\";"); eval("echo \"" . getTemplate('update/update_end') . "\";");
\Froxlor\User::updateCounters(); updateCounters();
\Froxlor\System\Cronjob::inserttask(\Froxlor\Cron\TaskId::REBUILD_VHOST); inserttask('1');
@chmod(\Froxlor\Froxlor::getInstallDir() . '/lib/userdata.inc.php', 0440); @chmod('./lib/userdata.inc.php', 0440);
$successful_update = true; $successful_update = true;
} else { } else {
@@ -94,7 +103,7 @@ if ($page == 'overview') {
} }
$update_information = $ui_text; $update_information = $ui_text;
include_once \Froxlor\Froxlor::getInstallDir() . '/install/updates/preconfig.php'; include_once './install/updates/preconfig.php';
$preconfig = getPreConfig($current_version, $current_db_version); $preconfig = getPreConfig($current_version, $current_db_version);
if ($preconfig != '') { if ($preconfig != '') {
$update_information .= '<br />' . $preconfig . $message; $update_information .= '<br />' . $preconfig . $message;
@@ -102,11 +111,11 @@ if ($page == 'overview') {
$update_information .= $lng['update']['update_information']['part_b']; $update_information .= $lng['update']['update_information']['part_b'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate('update/index') . "\";"); eval("echo \"" . getTemplate('update/index') . "\";");
} }
} else { } else {
$success_message = $lng['update']['noupdatesavail']; $success_message = $lng['update']['noupdatesavail'];
$redirect_url = 'admin_index.php?s=' . $s; $redirect_url = 'admin_index.php?s=' . $s;
eval("echo \"" . \Froxlor\UI\Template::getTemplate('update/noupdatesavail') . "\";"); eval("echo \"" . getTemplate('update/noupdatesavail') . "\";");
} }
} }

88
api.php
View File

@@ -1,88 +0,0 @@
<?php
use voku\helper\AntiXSS;
require __DIR__ . '/vendor/autoload.php';
require \Froxlor\Froxlor::getInstallDir() . '/lib/tables.inc.php';
// check whether API interface is enabled after all
if (\Froxlor\Settings::Get('api.enabled') != 1) {
// not enabled
header("Status: 404 Not found", 404);
header($_SERVER["SERVER_PROTOCOL"] . " 404 Not found", 404);
exit();
}
// we're talking json here
header("Content-Type:application/json");
// get our request
$request = @file_get_contents('php://input');
// check if present
if (empty($request)) {
json_response(400, "Invalid request");
}
// decode json request
$decoded_request = json_decode($request, true);
// is it valid?
if (is_null($decoded_request)) {
json_response(400, "Invalid JSON");
}
/**
* check for xss attempts and clean request
*/
$antiXss = new AntiXSS();
$request = $antiXss->xss_clean($request);
// validate content
try {
$decoded_request = stripcslashes_deep($decoded_request);
$request = \Froxlor\Api\FroxlorRPC::validateRequest($decoded_request);
// now actually do it
$cls = "\\Froxlor\\Api\\Commands\\" . $request['command']['class'];
$method = $request['command']['method'];
$apiObj = new $cls($decoded_request['header'], $request['params']);
// call the method with the params if any
echo $apiObj->$method();
} catch (Exception $e) {
json_response($e->getCode(), $e->getMessage());
}
exit();
/**
* output json result
*
* @param int $status
* @param string $status_message
* @param mixed $data
*
* @return void
*/
function json_response($status, $status_message = '', $data = null)
{
if (isset($_SERVER["SERVER_PROTOCOL"]) && ! empty($_SERVER["SERVER_PROTOCOL"])) {
$resheader = $_SERVER["SERVER_PROTOCOL"] . " " . $status;
if (! empty($status_message)) {
$resheader .= ' ' . str_replace("\n", " ", $status_message);
}
header($resheader);
}
$response = array();
$response['status'] = $status;
$response['status_message'] = $status_message;
$response['data'] = $data;
$json_response = json_encode($response, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
echo $json_response;
exit();
}
function stripcslashes_deep($value)
{
return is_array($value) ? array_map('stripcslashes_deep', $value) : stripcslashes($value);
}

View File

@@ -1,255 +0,0 @@
<?php
if (!defined('AREA')) {
header("Location: index.php");
exit();
}
/**
* This file is part of the Froxlor project.
* Copyright (c) 2018 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2018-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Panel
* @since 0.10.0
*
*/
use Froxlor\Database\Database;
// 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");
$success_message = "";
$id = isset($_POST['id']) ? (int) $_POST['id'] : (isset($_GET['id']) ? (int) $_GET['id'] : 0);
$area = AREA;
// do the delete and then just show a success-message and the apikeys list again
if ($action == 'delete') {
if ($id > 0) {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
$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, array(
'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, array(
'id' => $id,
'aid' => $userinfo['adminid']
));
}
if ($chk !== false) {
Database::pexecute($del_stmt, array(
'id' => $id
));
$success_message = sprintf($lng['apikeys']['apikey_removed'], $id);
}
} else {
\Froxlor\UI\HTML::askYesNo('api_reallydelete', $filename, array(
'page' => $page,
'action' => $action,
'id' => $id
), $id);
}
}
} 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, array(
'key' => $key,
'secret' => $secret,
'aid' => $userinfo['adminid'],
'cid' => $cid
));
$success_message = $lng['apikeys']['apikey_added'];
} else {
\Froxlor\UI\HTML::askYesNo('api_reallyadd', $filename, array(
'page' => $page,
'action' => $action
), $id);
}
} elseif ($action == 'jqEditApiKey') {
$keyid = isset($_POST['id']) ? (int) $_POST['id'] : 0;
if (empty($keyid)) {
echo json_encode(false);
exit;
}
$allowed_from = isset($_POST['allowed_from']) ? $_POST['allowed_from'] : "";
$valid_until = isset($_POST['valid_until']) ? (int) $_POST['valid_until'] : -1;
// validate allowed_from
if (!empty($allowed_from)) {
$ip_list = array_map('trim', explode(",", $allowed_from));
$_check_list = $ip_list;
foreach ($_check_list as $idx => $ip) {
if (\Froxlor\Validate\Validate::validate_ip2($ip, true, 'invalidip', true, true) == false) {
unset($ip_list[$idx]);
}
}
$ip_list = array_map('inet_ntop', array_map('inet_pton', $ip_list));
$allowed_from = implode(",", array_unique($ip_list));
}
if ($valid_until <= 0 || !is_numeric($valid_until)) {
$valid_until = -1;
}
$upd_stmt = Database::prepare("
UPDATE `" . TABLE_API_KEYS . "` SET
`valid_until` = :vu, `allowed_from` = :af
WHERE `id` = :keyid AND `adminid` = :aid AND `customerid` = :cid
");
if (AREA == 'admin') {
$cid = 0;
} elseif (AREA == 'customer') {
$cid = $userinfo['customerid'];
}
Database::pexecute($upd_stmt, array(
'keyid' => $keyid,
'af' => $allowed_from,
'vu' => $valid_until,
'aid' => $userinfo['adminid'],
'cid' => $cid
));
echo json_encode(true);
exit();
}
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed api::api_keys");
// select all my (accessible) certificates
$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 = array();
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 = array(
'a.loginname' => $lng['login']['username']
);
} elseif (AREA == 'customer') {
// customer-area
$keys_stmt_query .= "ak.customerid = :cid ";
$qry_params['cid'] = $userinfo['customerid'];
$fields = array(
'c.loginname' => $lng['login']['username']
);
} else {
// admin who can see all customers / reseller / admins
$keys_stmt_query .= "1 ";
$fields = array(
'a.loginname' => $lng['login']['username']
);
}
$paging = new \Froxlor\UI\Paging($userinfo, TABLE_API_KEYS, $fields);
$keys_stmt_query .= $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit();
$keys_stmt = Database::prepare($keys_stmt_query);
Database::pexecute($keys_stmt, $qry_params);
$all_keys = $keys_stmt->fetchAll(PDO::FETCH_ASSOC);
$apikeys = "";
if (count($all_keys) == 0) {
$count = 0;
$message = $lng['apikeys']['no_api_keys'];
$sortcode = "";
$searchcode = "";
$pagingcode = "";
eval("\$apikeys.=\"" . \Froxlor\UI\Template::getTemplate("api_keys/keys_error", true) . "\";");
} else {
$count = count($all_keys);
$paging->setEntries($count);
$sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
foreach ($all_keys as $idx => $key) {
if ($paging->checkDisplay($idx)) {
// my own key
$isMyKey = false;
if ($key['adminid'] == $userinfo['adminid'] && ((AREA == 'admin' && $key['customerid'] == 0) || (AREA == 'customer' && $key['customerid'] == $userinfo['customerid']))) {
// this is mine
$isMyKey = true;
}
$adminCustomerLink = "";
if (AREA == 'admin') {
if ($isMyKey) {
$adminCustomerLink = $key['adminname'];
} else {
$adminCustomerLink = '<a href="' . $linker->getLink(array(
'section' => (empty($key['customerid']) ? 'admins' : 'customers'),
'page' => (empty($key['customerid']) ? 'admins' : 'customers'),
'action' => 'su',
'id' => (empty($key['customerid']) ? $key['adminid'] : $key['customerid'])
)) . '" rel="external">' . (empty($key['customerid']) ? $key['adminname'] : $key['loginname']) . '</a>';
}
} else {
// customer do not need links
$adminCustomerLink = $key['loginname'];
}
// escape stuff
$row = \Froxlor\PhpHelper::htmlentitiesArray($key);
// shorten keys
$row['_apikey'] = substr($row['apikey'], 0, 20) . '...';
$row['_secret'] = substr($row['secret'], 0, 20) . '...';
// check whether the api key is not valid anymore
$isValid = true;
if ($row['valid_until'] >= 0) {
if ($row['valid_until'] < time()) {
$isValid = false;
}
// format
$row['valid_until'] = date('Y-m-d', $row['valid_until']);
} else {
// infinity
$row['valid_until'] = "";
}
eval("\$apikeys.=\"" . \Froxlor\UI\Template::getTemplate("api_keys/keys_key", true) . "\";");
} else {
continue;
}
}
}
eval("echo \"" . \Froxlor\UI\Template::getTemplate("api_keys/keys_list", true) . "\";");

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>

View File

@@ -1,81 +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"
},
{
"name": "Robert Förster",
"email": "team@froxlor.org",
"role": "Package Maintainer"
}
],
"support": {
"email": "team@froxlor.org",
"issues": "https://github.com/Froxlor/Froxlor/issues",
"forum": "https://forum.froxlor.org/",
"wiki": "https://github.com/Froxlor/Froxlor/wiki",
"irc": "irc://irc.libera.chat/froxlor",
"source": "https://github.com/Froxlor/Froxlor",
"docs": "https://github.com/Froxlor/Froxlor/wiki"
},
"require": {
"php": "^7.1 || ^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": "*",
"phpmailer/phpmailer": "~6.0",
"monolog/monolog": "^1.24",
"robthree/twofactorauth": "^1.6",
"froxlor/idna-convert-legacy": "^2.1",
"voku/anti-xss": "^4.1"
},
"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"
},
"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"
}
}

4242
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 387 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 287 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

1896
css/jquery-ui.min.css vendored

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -19,14 +19,9 @@
define('AREA', 'customer'); define('AREA', 'customer');
require './lib/init.php'; require './lib/init.php';
use Froxlor\Settings;
use Froxlor\Api\Commands\DirOptions as DirOptions;
use Froxlor\Api\Commands\DirProtections as DirProtections;
use Froxlor\Api\Commands\CustomerBackups as CustomerBackups;
// redirect if this customer page is hidden via settings // redirect if this customer page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options','extras')) { if (Settings::IsInList('panel.customer_hide_options','extras')) {
\Froxlor\UI\Response::redirectTo('customer_index.php'); redirectTo('customer_index.php');
} }
if (isset($_POST['id'])) { if (isset($_POST['id'])) {
@@ -36,70 +31,74 @@ if (isset($_POST['id'])) {
} }
if ($page == 'overview') { if ($page == 'overview') {
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_extras"); $log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_extras");
eval("echo \"" . \Froxlor\UI\Template::getTemplate("extras/extras") . "\";"); eval("echo \"" . getTemplate("extras/extras") . "\";");
} elseif ($page == 'htpasswds') { } elseif ($page == 'htpasswds') {
// redirect if this customer sub-page is hidden via settings // redirect if this customer sub-page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options','extras.directoryprotection')) { if (Settings::IsInList('panel.customer_hide_options','extras.directoryprotection')) {
\Froxlor\UI\Response::redirectTo('customer_index.php'); redirectTo('customer_index.php');
} }
if ($action == '') { if ($action == '') {
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_extras::htpasswds"); $log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_extras::htpasswds");
$fields = array( $fields = array(
'username' => $lng['login']['username'], 'username' => $lng['login']['username'],
'path' => $lng['panel']['path'] 'path' => $lng['panel']['path']
); );
try { $paging = new paging($userinfo, TABLE_PANEL_HTPASSWDS, $fields);
// get total count $result_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_HTPASSWDS . "`
$json_result = DirProtections::getLocal($userinfo)->listingCount(); WHERE `customerid`= :customerid " . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
$result = json_decode($json_result, true)['data']; Database::pexecute($result_stmt, array(
// initialize pagination and filtering "customerid" => $userinfo['customerid']
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result); ));
// get list $paging->setEntries(Database::num_rows());
$json_result = DirProtections::getLocal($userinfo, $paging->getApiCommandParams())->listing();
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$sortcode = $paging->getHtmlSortCode($lng); $sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s); $arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng); $searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s); $pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$i = 0;
$count = 0; $count = 0;
$htpasswds = ''; $htpasswds = '';
foreach ($result['list'] as $row) { while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
if ($paging->checkDisplay($i)) {
if (strpos($row['path'], $userinfo['documentroot']) === 0) { if (strpos($row['path'], $userinfo['documentroot']) === 0) {
$row['path'] = str_replace($userinfo['documentroot'], "/", $row['path']); $row['path'] = str_replace($userinfo['documentroot'], "/", $row['path']);
} }
$row['path'] = \Froxlor\FileDir::makeCorrectDir($row['path']); $row['path'] = makeCorrectDir($row['path']);
$row = \Froxlor\PhpHelper::htmlentitiesArray($row); $row = htmlentities_array($row);
eval("\$htpasswds.=\"" . \Froxlor\UI\Template::getTemplate("extras/htpasswds_htpasswd") . "\";"); eval("\$htpasswds.=\"" . getTemplate("extras/htpasswds_htpasswd") . "\";");
$count ++; $count ++;
} }
eval("echo \"" . \Froxlor\UI\Template::getTemplate("extras/htpasswds") . "\";"); $i ++;
} elseif ($action == 'delete' && $id != 0) {
try {
$json_result = DirProtections::getLocal($userinfo, array(
'id' => $id
))->get();
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data'];
eval("echo \"" . getTemplate("extras/htpasswds") . "\";");
} elseif ($action == 'delete' && $id != 0) {
$result_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_HTPASSWDS . "`
WHERE `customerid`= :customerid
AND `id`= :id");
Database::pexecute($result_stmt, array(
"customerid" => $userinfo['customerid'],
"id" => $id
));
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
if (isset($result['username']) && $result['username'] != '') { if (isset($result['username']) && $result['username'] != '') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { $stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_HTPASSWDS . "`
DirProtections::getLocal($userinfo, $_POST)->delete(); WHERE `customerid`= :customerid
} catch (Exception $e) { AND `id`= :id");
\Froxlor\UI\Response::dynamic_error($e->getMessage()); Database::pexecute($stmt, array(
} "customerid" => $userinfo['customerid'],
\Froxlor\UI\Response::redirectTo($filename, array( "id" => $id
));
$log->logAction(USR_ACTION, LOG_INFO, "deleted htpasswd for '" . $result['username'] . " (" . $result['path'] . ")'");
inserttask('1');
redirectTo($filename, array(
'page' => $page, 'page' => $page,
's' => $s 's' => $s
)); ));
@@ -108,7 +107,7 @@ if ($page == 'overview') {
$result['path'] = str_replace($userinfo['documentroot'], "/", $result['path']); $result['path'] = str_replace($userinfo['documentroot'], "/", $result['path']);
} }
\Froxlor\UI\HTML::askYesNo('extras_reallydelete', $filename, array( ask_yesno('extras_reallydelete', $filename, array(
'id' => $id, 'id' => $id,
'page' => $page, 'page' => $page,
'action' => $action 'action' => $action
@@ -117,61 +116,159 @@ if ($page == 'overview') {
} }
} elseif ($action == 'add') { } elseif ($action == 'add') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { $path = makeCorrectDir(validate($_POST['path'], 'path'));
DirProtections::getLocal($userinfo, $_POST)->add(); $userpath = $path;
} catch (Exception $e) { $path = makeCorrectDir($userinfo['documentroot'] . '/' . $path);
\Froxlor\UI\Response::dynamic_error($e->getMessage()); $username = validate($_POST['username'], 'username', '/^[a-zA-Z0-9][a-zA-Z0-9\-_]+\$?$/');
$authname = validate($_POST['directory_authname'], 'directory_authname', '/^[a-zA-Z0-9][a-zA-Z0-9\-_ ]+\$?$/');
validate($_POST['directory_password'], 'password');
$username_path_check_stmt = Database::prepare("SELECT `id`, `username`, `path` FROM `" . TABLE_PANEL_HTPASSWDS . "`
WHERE `username`= :username
AND `path`= :path
AND `customerid`= :customerid");
$params = array(
"username" => $username,
"path" => $path,
"customerid" => $userinfo['customerid']
);
Database::pexecute($username_path_check_stmt, $params);
$username_path_check = $username_path_check_stmt->fetch(PDO::FETCH_ASSOC);
if (CRYPT_STD_DES == 1) {
$saltfordescrypt = substr(md5(uniqid(microtime(), 1)), 4, 2);
$password = crypt($_POST['directory_password'], $saltfordescrypt);
} else {
$password = crypt($_POST['directory_password']);
} }
\Froxlor\UI\Response::redirectTo($filename, array(
if (! $_POST['path']) {
standard_error('invalidpath');
}
if ($username == '') {
standard_error(array(
'stringisempty',
'myloginname'
));
} elseif ($username_path_check['username'] == $username && $username_path_check['path'] == $path) {
standard_error('userpathcombinationdupe');
} elseif ($_POST['directory_password'] == '') {
standard_error(array(
'stringisempty',
'mypassword'
));
} elseif ($path == '') {
standard_error('patherror');
} elseif ($_POST['directory_password'] == $username) {
standard_error('passwordshouldnotbeusername');
} else {
$stmt = Database::prepare("INSERT INTO `" . TABLE_PANEL_HTPASSWDS . "` SET
`customerid` = :customerid,
`username` = :username,
`password` = :password,
`path` = :path,
`authname` = :authname");
$params = array(
"customerid" => $userinfo['customerid'],
"username" => $username,
"password" => $password,
"path" => $path,
"authname" => $authname
);
Database::pexecute($stmt, $params);
$log->logAction(USR_ACTION, LOG_INFO, "added htpasswd for '" . $username . " (" . $path . ")'");
inserttask('1');
redirectTo($filename, array(
'page' => $page, 'page' => $page,
's' => $s 's' => $s
)); ));
}
} else { } else {
$pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']); $pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']);
$htpasswd_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htpasswd_add.php'; $htpasswd_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htpasswd_add.php';
$htpasswd_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($htpasswd_add_data); $htpasswd_add_form = htmlform::genHTMLForm($htpasswd_add_data);
$title = $htpasswd_add_data['htpasswd_add']['title']; $title = $htpasswd_add_data['htpasswd_add']['title'];
$image = $htpasswd_add_data['htpasswd_add']['image']; $image = $htpasswd_add_data['htpasswd_add']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate("extras/htpasswds_add") . "\";"); eval("echo \"" . getTemplate("extras/htpasswds_add") . "\";");
} }
} elseif ($action == 'edit' && $id != 0) { } elseif ($action == 'edit' && $id != 0) {
try { $result_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_HTPASSWDS . "`
$json_result = DirProtections::getLocal($userinfo, array( WHERE `customerid`= :customerid
'id' => $id AND `id`= :id");
))->get(); Database::pexecute($result_stmt, array(
} catch (Exception $e) { "customerid" => $userinfo['customerid'],
\Froxlor\UI\Response::dynamic_error($e->getMessage()); "id" => $id
} ));
$result = json_decode($json_result, true)['data']; $result = $result_stmt->fetch(PDO::FETCH_ASSOC);
if (isset($result['username']) && $result['username'] != '') { if (isset($result['username']) && $result['username'] != '') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { validate($_POST['directory_password'], 'password');
DirProtections::getLocal($userinfo, $_POST)->update(); $authname = validate($_POST['directory_authname'], 'directory_authname', '/^[a-zA-Z0-9][a-zA-Z0-9\-_ ]+\$?$/');
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage()); if (CRYPT_STD_DES == 1) {
$saltfordescrypt = substr(md5(uniqid(microtime(), 1)), 4, 2);
$password = crypt($_POST['directory_password'], $saltfordescrypt);
} else {
$password = crypt($_POST['directory_password']);
} }
\Froxlor\UI\Response::redirectTo($filename, array(
if ($_POST['directory_password'] == $result['username']) {
standard_error('passwordshouldnotbeusername');
}
$params = array(
"customerid" => $userinfo['customerid'],
"id" => $id
);
$pwd_sql = '';
if ($_POST['directory_password'] != '') {
$pwd_sql = "`password`= :password ";
$params["password"] = $password;
}
$auth_sql = '';
if ($authname != $result['authname']) {
$auth_sql = "`authname`= :authname ";
$params["authname"] = $authname;
}
if ($pwd_sql != '' || $auth_sql != '') {
if ($pwd_sql != '' && $auth_sql != '') {
$pwd_sql .= ', ';
}
$stmt = Database::prepare("UPDATE `" . TABLE_PANEL_HTPASSWDS . "`
SET " . $pwd_sql . $auth_sql . "
WHERE `customerid`= :customerid
AND `id`= :id");
Database::pexecute($stmt, $params);
$log->logAction(USR_ACTION, LOG_INFO, "edited htpasswd for '" . $result['username'] . " (" . $result['path'] . ")'");
inserttask('1');
redirectTo($filename, array(
'page' => $page, 'page' => $page,
's' => $s 's' => $s
)); ));
}
} else { } else {
if (strpos($result['path'], $userinfo['documentroot']) === 0) { if (strpos($result['path'], $userinfo['documentroot']) === 0) {
$result['path'] = str_replace($userinfo['documentroot'], "/", $result['path']); $result['path'] = str_replace($userinfo['documentroot'], "/", $result['path']);
} }
$result = \Froxlor\PhpHelper::htmlentitiesArray($result); $result = htmlentities_array($result);
$htpasswd_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htpasswd_edit.php'; $htpasswd_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htpasswd_edit.php';
$htpasswd_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($htpasswd_edit_data); $htpasswd_edit_form = htmlform::genHTMLForm($htpasswd_edit_data);
$title = $htpasswd_edit_data['htpasswd_edit']['title']; $title = $htpasswd_edit_data['htpasswd_edit']['title'];
$image = $htpasswd_edit_data['htpasswd_edit']['image']; $image = $htpasswd_edit_data['htpasswd_edit']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate("extras/htpasswds_edit") . "\";"); eval("echo \"" . getTemplate("extras/htpasswds_edit") . "\";");
} }
} }
} }
@@ -179,11 +276,11 @@ if ($page == 'overview') {
// redirect if this customer sub-page is hidden via settings // redirect if this customer sub-page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options','extras.pathoptions')) { if (Settings::IsInList('panel.customer_hide_options','extras.pathoptions')) {
\Froxlor\UI\Response::redirectTo('customer_index.php'); redirectTo('customer_index.php');
} }
if ($action == '') { if ($action == '') {
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_extras::htaccess"); $log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_extras::htaccess");
$fields = array( $fields = array(
'path' => $lng['panel']['path'], 'path' => $lng['panel']['path'],
'options_indexes' => $lng['extras']['view_directory'], 'options_indexes' => $lng['extras']['view_directory'],
@@ -192,66 +289,85 @@ if ($page == 'overview') {
'error500path' => $lng['extras']['error500path'], 'error500path' => $lng['extras']['error500path'],
'options_cgi' => $lng['extras']['execute_perl'] 'options_cgi' => $lng['extras']['execute_perl']
); );
try { $paging = new paging($userinfo, TABLE_PANEL_HTACCESS, $fields);
// get total count $result_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_HTACCESS . "`
$json_result = DirOptions::getLocal($userinfo)->listingCount(); WHERE `customerid`= :customerid " . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
$result = json_decode($json_result, true)['data']; Database::pexecute($result_stmt, array(
// initialize pagination and filtering "customerid" => $userinfo['customerid']
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result); ));
// get list $paging->setEntries(Database::num_rows());
$json_result = DirOptions::getLocal($userinfo, $paging->getApiCommandParams())->listing();
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$sortcode = $paging->getHtmlSortCode($lng); $sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s); $arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng); $searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s); $pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$i = 0;
$count = 0; $count = 0;
$htaccess = ''; $htaccess = '';
$cperlenabled = \Froxlor\Customer\Customer::customerHasPerlEnabled($userinfo['customerid']); $cperlenabled = customerHasPerlEnabled($userinfo['customerid']);
foreach ($result['list'] as $row) { while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
if ($paging->checkDisplay($i)) {
if (strpos($row['path'], $userinfo['documentroot']) === 0) { if (strpos($row['path'], $userinfo['documentroot']) === 0) {
$row['path'] = str_replace($userinfo['documentroot'], "/", $row['path']); $row['path'] = str_replace($userinfo['documentroot'], "/", $row['path']);
} }
$row['path'] = \Froxlor\FileDir::makeCorrectDir($row['path']); $row['path'] = makeCorrectDir($row['path']);
$row['options_indexes'] = str_replace('1', $lng['panel']['yes'], $row['options_indexes']); $row['options_indexes'] = str_replace('1', $lng['panel']['yes'], $row['options_indexes']);
$row['options_indexes'] = str_replace('0', $lng['panel']['no'], $row['options_indexes']); $row['options_indexes'] = str_replace('0', $lng['panel']['no'], $row['options_indexes']);
$row['options_cgi'] = str_replace('1', $lng['panel']['yes'], $row['options_cgi']); $row['options_cgi'] = str_replace('1', $lng['panel']['yes'], $row['options_cgi']);
$row['options_cgi'] = str_replace('0', $lng['panel']['no'], $row['options_cgi']); $row['options_cgi'] = str_replace('0', $lng['panel']['no'], $row['options_cgi']);
$row = \Froxlor\PhpHelper::htmlentitiesArray($row); $row = htmlentities_array($row);
eval("\$htaccess.=\"" . \Froxlor\UI\Template::getTemplate("extras/htaccess_htaccess") . "\";"); eval("\$htaccess.=\"" . getTemplate("extras/htaccess_htaccess") . "\";");
$count ++; $count ++;
} }
eval("echo \"" . \Froxlor\UI\Template::getTemplate("extras/htaccess") . "\";"); $i ++;
} elseif ($action == 'delete' && $id != 0) {
try {
$json_result = DirOptions::getLocal($userinfo, array(
'id' => $id
))->get();
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data'];
eval("echo \"" . getTemplate("extras/htaccess") . "\";");
} elseif ($action == 'delete' && $id != 0) {
$result_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_HTACCESS . "`
WHERE `customerid` = :customerid
AND `id` = :id");
Database::pexecute($result_stmt, array(
"customerid" => $userinfo['customerid'],
"id" => $id
));
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
if (isset($result['customerid']) && $result['customerid'] != '' && $result['customerid'] == $userinfo['customerid']) { if (isset($result['customerid']) && $result['customerid'] != '' && $result['customerid'] == $userinfo['customerid']) {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { // do we have to remove the symlink and folder in suexecpath?
DirOptions::getLocal($userinfo, $_POST)->delete(); if ((int) Settings::Get('perl.suexecworkaround') == 1) {
} catch (Exception $e) { $loginname = getCustomerDetail($result['customerid'], 'loginname');
\Froxlor\UI\Response::dynamic_error($e->getMessage()); $suexecpath = makeCorrectDir(Settings::Get('perl.suexecpath') . '/' . $loginname . '/' . md5($result['path']) . '/');
$perlsymlink = makeCorrectFile($result['path'] . '/cgi-bin');
// remove symlink
if (file_exists($perlsymlink)) {
safe_exec('rm -f ' . escapeshellarg($perlsymlink));
$log->logAction(USR_ACTION, LOG_DEBUG, "deleted suexecworkaround symlink '" . $perlsymlink . "'");
} }
\Froxlor\UI\Response::redirectTo($filename, array( // remove folder in suexec-path
if (file_exists($suexecpath)) {
safe_exec('rm -rf ' . escapeshellarg($suexecpath));
$log->logAction(USR_ACTION, LOG_DEBUG, "deleted suexecworkaround path '" . $suexecpath . "'");
}
}
$stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_HTACCESS . "`
WHERE `customerid`= :customerid
AND `id`= :id");
Database::pexecute($stmt, array(
"customerid" => $userinfo['customerid'],
"id" => $id
));
$log->logAction(USR_ACTION, LOG_INFO, "deleted htaccess for '" . str_replace($userinfo['documentroot'], '/', $result['path']) . "'");
inserttask('1');
redirectTo($filename, array(
'page' => $page, 'page' => $page,
's' => $s 's' => $s
)); ));
} else { } else {
\Froxlor\UI\HTML::askYesNo('extras_reallydelete_pathoptions', $filename, array( ask_yesno('extras_reallydelete_pathoptions', $filename, array(
'id' => $id, 'id' => $id,
'page' => $page, 'page' => $page,
'action' => $action 'action' => $action
@@ -260,45 +376,137 @@ if ($page == 'overview') {
} }
} elseif ($action == 'add') { } elseif ($action == 'add') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { $path = makeCorrectDir(validate($_POST['path'], 'path'));
DirOptions::getLocal($userinfo, $_POST)->add(); $userpath = $path;
} catch (Exception $e) { $path = makeCorrectDir($userinfo['documentroot'] . '/' . $path);
\Froxlor\UI\Response::dynamic_error($e->getMessage()); $path_dupe_check_stmt = Database::prepare("SELECT `id`, `path` FROM `" . TABLE_PANEL_HTACCESS . "`
WHERE `path`= :path
AND `customerid`= :customerid");
Database::pexecute($path_dupe_check_stmt, array(
"path" => $path,
"customerid" => $userinfo['customerid']
));
$path_dupe_check = $path_dupe_check_stmt->fetch(PDO::FETCH_ASSOC);
if (! $_POST['path']) {
standard_error('invalidpath');
} }
\Froxlor\UI\Response::redirectTo($filename, array(
if (isset($_POST['options_cgi']) && (int) $_POST['options_cgi'] != 0) {
$options_cgi = '1';
} else {
$options_cgi = '0';
}
$error404path = '';
if (isset($_POST['error404path'])) {
$error404path = correctErrorDocument($_POST['error404path']);
}
$error403path = '';
if (isset($_POST['error403path'])) {
$error403path = correctErrorDocument($_POST['error403path']);
}
$error500path = '';
if (isset($_POST['error500path'])) {
$error500path = correctErrorDocument($_POST['error500path']);
}
if ($path_dupe_check['path'] == $path) {
standard_error('errordocpathdupe', $userpath);
} elseif ($path == '') {
standard_error('patherror');
} else {
$stmt = Database::prepare('INSERT INTO `' . TABLE_PANEL_HTACCESS . '` SET
`customerid` = :customerid,
`path` = :path,
`options_indexes` = :options_indexes,
`error404path` = :error404path,
`error403path` = :error403path,
`error500path` = :error500path,
`options_cgi` = :options_cgi');
$params = array(
"customerid" => $userinfo['customerid'],
"path" => $path,
"options_indexes" => $_POST['options_indexes'] == '1' ? '1' : '0',
"error403path" => $error403path,
"error404path" => $error404path,
"error500path" => $error500path,
"options_cgi" => $options_cgi
);
Database::pexecute($stmt, $params);
$log->logAction(USR_ACTION, LOG_INFO, "added htaccess for '" . $path . "'");
inserttask('1');
redirectTo($filename, array(
'page' => $page, 'page' => $page,
's' => $s 's' => $s
)); ));
}
} else { } else {
$pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']); $pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']);
$cperlenabled = \Froxlor\Customer\Customer::customerHasPerlEnabled($userinfo['customerid']); $cperlenabled = customerHasPerlEnabled($userinfo['customerid']);
$htaccess_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htaccess_add.php'; $htaccess_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htaccess_add.php';
$htaccess_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($htaccess_add_data); $htaccess_add_form = htmlform::genHTMLForm($htaccess_add_data);
$title = $htaccess_add_data['htaccess_add']['title']; $title = $htaccess_add_data['htaccess_add']['title'];
$image = $htaccess_add_data['htaccess_add']['image']; $image = $htaccess_add_data['htaccess_add']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate("extras/htaccess_add") . "\";"); eval("echo \"" . getTemplate("extras/htaccess_add") . "\";");
} }
} elseif (($action == 'edit') && ($id != 0)) { } elseif (($action == 'edit') && ($id != 0)) {
try { $result_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_HTACCESS . "`
$json_result = DirOptions::getLocal($userinfo, array( WHERE `customerid` = :customerid
'id' => $id AND `id` = :id");
))->get(); Database::pexecute($result_stmt, array(
} catch (Exception $e) { "customerid" => $userinfo['customerid'],
\Froxlor\UI\Response::dynamic_error($e->getMessage()); "id" => $id
} ));
$result = json_decode($json_result, true)['data']; $result = $result_stmt->fetch(PDO::FETCH_ASSOC);
if ((isset($result['customerid'])) && ($result['customerid'] != '') && ($result['customerid'] == $userinfo['customerid'])) { if ((isset($result['customerid'])) && ($result['customerid'] != '') && ($result['customerid'] == $userinfo['customerid'])) {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { $option_indexes = intval($_POST['options_indexes']);
DirOptions::getLocal($userinfo, $_POST)->update(); $options_cgi = isset($_POST['options_cgi']) ? intval($_POST['options_cgi']) : 0;
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage()); if ($option_indexes != '1') {
$option_indexes = '0';
} }
\Froxlor\UI\Response::redirectTo($filename, array(
if ($options_cgi != '1') {
$options_cgi = '0';
}
$error404path = correctErrorDocument($_POST['error404path']);
$error403path = correctErrorDocument($_POST['error403path']);
$error500path = correctErrorDocument($_POST['error500path']);
if (($option_indexes != $result['options_indexes']) || ($error404path != $result['error404path']) || ($error403path != $result['error403path']) || ($error500path != $result['error500path']) || ($options_cgi != $result['options_cgi'])) {
inserttask('1');
$stmt = Database::prepare("UPDATE `" . TABLE_PANEL_HTACCESS . "`
SET `options_indexes` = :options_indexes,
`error404path` = :error404path,
`error403path` = :error403path,
`error500path` = :error500path,
`options_cgi` = :options_cgi
WHERE `customerid` = :customerid
AND `id` = :id");
$params = array(
"customerid" => $userinfo['customerid'],
"options_indexes" => $_POST['options_indexes'] == '1' ? '1' : '0',
"error403path" => $error403path,
"error404path" => $error404path,
"error500path" => $error500path,
"options_cgi" => $options_cgi,
"id" => $id
);
Database::pexecute($stmt, $params);
$log->logAction(USR_ACTION, LOG_INFO, "edited htaccess for '" . str_replace($userinfo['documentroot'], '/', $result['path']) . "'");
}
redirectTo($filename, array(
'page' => $page, 'page' => $page,
's' => $s 's' => $s
)); ));
@@ -310,20 +518,20 @@ if ($page == 'overview') {
$result['error404path'] = $result['error404path']; $result['error404path'] = $result['error404path'];
$result['error403path'] = $result['error403path']; $result['error403path'] = $result['error403path'];
$result['error500path'] = $result['error500path']; $result['error500path'] = $result['error500path'];
$cperlenabled = \Froxlor\Customer\Customer::customerHasPerlEnabled($userinfo['customerid']); $cperlenabled = customerHasPerlEnabled($userinfo['customerid']);
/* /*
* $options_indexes = \Froxlor\UI\HTML::makeyesno('options_indexes', '1', '0', $result['options_indexes']); * $options_indexes = makeyesno('options_indexes', '1', '0', $result['options_indexes']);
* $options_cgi = \Froxlor\UI\HTML::makeyesno('options_cgi', '1', '0', $result['options_cgi']); * $options_cgi = makeyesno('options_cgi', '1', '0', $result['options_cgi']);
*/ */
$result = \Froxlor\PhpHelper::htmlentitiesArray($result); $result = htmlentities_array($result);
$htaccess_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htaccess_edit.php'; $htaccess_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htaccess_edit.php';
$htaccess_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($htaccess_edit_data); $htaccess_edit_form = htmlform::genHTMLForm($htaccess_edit_data);
$title = $htaccess_edit_data['htaccess_edit']['title']; $title = $htaccess_edit_data['htaccess_edit']['title'];
$image = $htaccess_edit_data['htaccess_edit']['image']; $image = $htaccess_edit_data['htaccess_edit']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate("extras/htaccess_edit") . "\";"); eval("echo \"" . getTemplate("extras/htaccess_edit") . "\";");
} }
} }
} }
@@ -331,71 +539,107 @@ if ($page == 'overview') {
// redirect if this customer sub-page is hidden via settings // redirect if this customer sub-page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options','extras.backup')) { if (Settings::IsInList('panel.customer_hide_options','extras.backup')) {
\Froxlor\UI\Response::redirectTo('customer_index.php'); redirectTo('customer_index.php');
} }
if (Settings::Get('system.backupenabled') == 1) { if (Settings::Get('system.backupenabled') == 1)
{
if ($action == 'abort' && isset($_POST['send']) && $_POST['send'] == 'send') { if ($action == 'abort' && isset($_POST['send']) && $_POST['send'] == 'send') {
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "customer_extras::backup - aborted scheduled backupjob"); $log->logAction(USR_ACTION, LOG_NOTICE, "customer_extras::backup - aborted scheduled backupjob");
try { $entry = isset($_POST['backup_job_entry']) ? (int)$_POST['backup_job_entry'] : 0;
CustomerBackups::getLocal($userinfo, $_POST)->delete(); if ($entry > 0) {
} catch (Exception $e) { $del_stmt = Database::prepare("DELETE FROM `".TABLE_PANEL_TASKS."` WHERE `id` = :tid");
\Froxlor\UI\Response::dynamic_error($e->getMessage()); Database::pexecute($del_stmt, array('tid' => $entry));
standard_success('backupaborted');
} }
\Froxlor\UI\Response::standard_success('backupaborted'); redirectTo($filename, array('page' => $page, 'action' => '', 's' => $s));
\Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page,
'action' => '',
's' => $s
));
} }
if ($action == '') { if ($action == '') {
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_extras::backup"); $log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_extras::backup");
// check whether there is a backup-job for this customer // check whether there is a backup-job for this customer
try { $sel_stmt = Database::prepare("SELECT * FROM `".TABLE_PANEL_TASKS."` WHERE `type` = '20'");
$json_result = CustomerBackups::getLocal($userinfo)->listing(); Database::pexecute($sel_stmt);
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$existing_backupJob = null; $existing_backupJob = null;
if ($result['count'] > 0) { while ($entry = $sel_stmt->fetch())
$existing_backupJob = array_shift($result['list']); {
$data = json_decode($entry['data'], true);
if ($data['customerid'] == $userinfo['customerid']) {
$existing_backupJob = $entry;
break;
}
} }
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try {
CustomerBackups::getLocal($userinfo, $_POST)->add(); if (! $_POST['path']) {
} catch (Exception $e) { standard_error('invalidpath');
\Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
\Froxlor\UI\Response::standard_success('backupscheduled');
$path = makeCorrectDir(validate($_POST['path'], 'path'));
$path = makeCorrectDir($userinfo['documentroot'] . '/' . $path);
// path cannot be the customers docroot
if ($path == makeCorrectDir($userinfo['documentroot'])) {
standard_error('backupfoldercannotbedocroot');
}
$backup_dbs = isset($_POST['backup_dbs']) ? intval($_POST['backup_dbs']) : 0;
$backup_mail = isset($_POST['backup_mail']) ? intval($_POST['backup_mail']) : 0;
$backup_web = isset($_POST['backup_web']) ? intval($_POST['backup_web']) : 0;
if ($backup_dbs != '1') {
$backup_dbs = '0';
}
if ($backup_mail != '1') {
$backup_mail = '0';
}
if ($backup_web != '1') {
$backup_web = '0';
}
$task_data = array(
'customerid' => $userinfo['customerid'],
'uid' => $userinfo['guid'],
'gid' => $userinfo['guid'],
'loginname' => $userinfo['loginname'],
'destdir' => $path,
'backup_dbs' => $backup_dbs,
'backup_mail' => $backup_mail,
'backup_web' => $backup_web
);
// schedule backup job
inserttask('20', $task_data);
standard_success('backupscheduled');
} else { } else {
if (!empty($existing_backupJob)) { if (!empty($existing_backupJob)) {
$action = "abort"; $action = "abort";
$row = $existing_backupJob['data']; $row = json_decode($entry['data'], true);
$row['path'] = makeCorrectDir(str_replace($userinfo['documentroot'], "/", $row['destdir']));
$row['path'] = \Froxlor\FileDir::makeCorrectDir(str_replace($userinfo['documentroot'], "/", $row['destdir']));
$row['backup_web'] = ($row['backup_web'] == '1') ? $lng['panel']['yes'] : $lng['panel']['no']; $row['backup_web'] = ($row['backup_web'] == '1') ? $lng['panel']['yes'] : $lng['panel']['no'];
$row['backup_mail'] = ($row['backup_mail'] == '1') ? $lng['panel']['yes'] : $lng['panel']['no']; $row['backup_mail'] = ($row['backup_mail'] == '1') ? $lng['panel']['yes'] : $lng['panel']['no'];
$row['backup_dbs'] = ($row['backup_dbs'] == '1') ? $lng['panel']['yes'] : $lng['panel']['no']; $row['backup_dbs'] = ($row['backup_dbs'] == '1') ? $lng['panel']['yes'] : $lng['panel']['no'];
} }
$pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']); $pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']);
$backup_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.backup.php'; $backup_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.backup.php';
$backup_form = \Froxlor\UI\HtmlForm::genHTMLForm($backup_data); $backup_form = htmlform::genHTMLForm($backup_data);
$title = $backup_data['backup']['title']; $title = $backup_data['backup']['title'];
$image = $backup_data['backup']['image']; $image = $backup_data['backup']['image'];
if (!empty($existing_backupJob)) { if (!empty($existing_backupJob)) {
// overwrite backup_form after we took everything from it we needed // overwrite backup_form after we took everything from it we needed
eval("\$backup_form = \"" . \Froxlor\UI\Template::getTemplate("extras/backup_listexisting") . "\";"); eval("\$backup_form = \"" . getTemplate("extras/backup_listexisting") . "\";");
} }
eval("echo \"" . \Froxlor\UI\Template::getTemplate("extras/backup") . "\";"); eval("echo \"" . getTemplate("extras/backup") . "\";");
} }
} }
} else { }
\Froxlor\UI\Response::standard_error('backupfunctionnotenabled'); else
{
standard_error('backupfunctionnotenabled');
} }
} }

View File

@@ -16,16 +16,13 @@
* @package Panel * @package Panel
* *
*/ */
define('AREA', 'customer'); define('AREA', 'customer');
require './lib/init.php'; require './lib/init.php';
use Froxlor\Database\Database;
use Froxlor\Settings;
use Froxlor\Api\Commands\Ftps as Ftps;
// redirect if this customer page is hidden via settings // redirect if this customer page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options','ftp')) { if (Settings::IsInList('panel.customer_hide_options','ftp')) {
\Froxlor\UI\Response::redirectTo('customer_index.php'); redirectTo('customer_index.php');
} }
$id = 0; $id = 0;
@@ -36,104 +33,304 @@ if (isset($_POST['id'])) {
} }
if ($page == 'overview') { if ($page == 'overview') {
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_ftp"); $log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_ftp");
eval("echo \"" . \Froxlor\UI\Template::getTemplate('ftp/ftp') . "\";"); eval("echo \"" . getTemplate('ftp/ftp') . "\";");
} elseif ($page == 'accounts') { } elseif ($page == 'accounts') {
if ($action == '') { if ($action == '') {
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_ftp::accounts"); $log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_ftp::accounts");
$fields = array( $fields = array(
'username' => $lng['login']['username'], 'username' => $lng['login']['username'],
'homedir' => $lng['panel']['path'], 'homedir' => $lng['panel']['path'],
'description' => $lng['panel']['ftpdesc'] 'description' => $lng['panel']['ftpdesc']
); );
try { $paging = new paging($userinfo, TABLE_FTP_USERS, $fields);
// get total count
$json_result = Ftps::getLocal($userinfo)->listingCount(); $result_stmt = Database::prepare("SELECT `id`, `username`, `description`, `homedir`, `shell` FROM `" . TABLE_FTP_USERS . "`
$result = json_decode($json_result, true)['data']; WHERE `customerid`= :customerid " . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit()
// initialize pagination and filtering );
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result); Database::pexecute($result_stmt, array("customerid" => $userinfo['customerid']));
// get list $ftps_count = Database::num_rows();
$json_result = Ftps::getLocal($userinfo, $paging->getApiCommandParams())->listing(); $paging->setEntries($ftps_count);
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$ftps_count = $paging->getEntries();
$sortcode = $paging->getHtmlSortCode($lng); $sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s); $arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng); $searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s); $pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$i = 0;
$count = 0; $count = 0;
$accounts = ''; $accounts = '';
foreach ($result['list'] as $row) { while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
if ($paging->checkDisplay($i)) {
if (strpos($row['homedir'], $userinfo['documentroot']) === 0) { if (strpos($row['homedir'], $userinfo['documentroot']) === 0) {
$row['documentroot'] = str_replace($userinfo['documentroot'], "/", $row['homedir']); $row['documentroot'] = str_replace($userinfo['documentroot'], "/", $row['homedir']);
} else { } else {
$row['documentroot'] = $row['homedir']; $row['documentroot'] = $row['homedir'];
} }
$row['documentroot'] = \Froxlor\FileDir::makeCorrectDir($row['documentroot']);
$row = \Froxlor\PhpHelper::htmlentitiesArray($row); $row['documentroot'] = makeCorrectDir($row['documentroot']);
eval("\$accounts.=\"" . \Froxlor\UI\Template::getTemplate('ftp/accounts_account') . "\";");
$row = htmlentities_array($row);
eval("\$accounts.=\"" . getTemplate('ftp/accounts_account') . "\";");
$count++; $count++;
} }
eval("echo \"" . \Froxlor\UI\Template::getTemplate('ftp/accounts') . "\";"); $i++;
} elseif ($action == 'delete' && $id != 0) {
try {
$json_result = Ftps::getLocal($userinfo, array(
'id' => $id
))->get();
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
$result = json_decode($json_result, true)['data'];
eval("echo \"" . getTemplate('ftp/accounts') . "\";");
} elseif ($action == 'delete' && $id != 0) {
$result_stmt = Database::prepare("SELECT `id`, `username`, `homedir`, `up_count`, `up_bytes`, `down_count`, `down_bytes` FROM `" . TABLE_FTP_USERS . "`
WHERE `customerid` = :customerid
AND `id` = :id"
);
Database::pexecute($result_stmt, array("customerid" => $userinfo['customerid'], "id" => $id));
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
if (isset($result['username']) && $result['username'] != $userinfo['loginname']) { if (isset($result['username']) && $result['username'] != $userinfo['loginname']) {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { $stmt = Database::prepare("UPDATE `" . TABLE_FTP_USERS . "`
Ftps::getLocal($userinfo, $_POST)->delete(); SET `up_count` = `up_count` + :up_count,
} catch (Exception $e) { `up_bytes` = `up_bytes` + :up_bytes,
\Froxlor\UI\Response::dynamic_error($e->getMessage()); `down_count` = `down_count` + :down_count,
} `down_bytes` = `down_bytes` + :down_bytes
\Froxlor\UI\Response::redirectTo($filename, array( WHERE `username` = :username"
'page' => $page, );
's' => $s $params = array(
)); "up_count" => $result['up_count'],
"up_bytes" => $result['up_bytes'],
"down_count" => $result['down_count'],
"down_bytes" => $result['down_bytes'],
"username" => $userinfo['loginname']
);
Database::pexecute($stmt, $params);
$result_stmt = Database::prepare("SELECT `username`, `homedir` FROM `" . TABLE_FTP_USERS . "`
WHERE `customerid` = :customerid
AND `id` = :id"
);
Database::pexecute($result_stmt, array("customerid" => $userinfo['customerid'], "id" => $id));
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
$stmt = Database::prepare("DELETE FROM `" . TABLE_FTP_QUOTATALLIES . "` WHERE `name` = :name");
Database::pexecute($stmt, array("name" => $result['username']));
$stmt = Database::prepare("DELETE FROM `" . TABLE_FTP_USERS . "`
WHERE `customerid` = :customerid
AND `id` = :id"
);
Database::pexecute($stmt, array("customerid" => $userinfo['customerid'], "id" => $id));
$stmt = Database::prepare("
UPDATE `" . TABLE_FTP_GROUPS . "` SET
`members` = REPLACE(`members`, :username,'')
WHERE `customerid` = :customerid
");
Database::pexecute($stmt, array("username" => ",".$result['username'], "customerid" => $userinfo['customerid']));
$log->logAction(USR_ACTION, LOG_INFO, "deleted ftp-account '" . $result['username'] . "'");
$resetaccnumber = ($userinfo['ftps_used'] == '1') ? " , `ftp_lastaccountnumber`='0'" : '';
// refs #293
if (isset($_POST['delete_userfiles']) && (int)$_POST['delete_userfiles'] == 1) {
inserttask('8', $userinfo['loginname'], $result['homedir']);
} else { } else {
\Froxlor\UI\HTML::askYesNoWithCheckbox('ftp_reallydelete', 'admin_customer_alsoremoveftphomedir', $filename, array( if (Settings::Get('system.nssextrausers') == 1)
'id' => $id, {
'page' => $page, // this is used so that the libnss-extrausers cron is fired
'action' => $action inserttask(5);
), $result['username']); }
}
$stmt = Database::prepare("UPDATE `" . TABLE_PANEL_CUSTOMERS . "`
SET `ftps_used` = `ftps_used` - 1 $resetaccnumber
WHERE `customerid` = :customerid"
);
Database::pexecute($stmt, array("customerid" => $userinfo['customerid']));
redirectTo($filename, array('page' => $page, 's' => $s));
} else {
ask_yesno_withcheckbox('ftp_reallydelete', 'admin_customer_alsoremoveftphomedir', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $result['username']);
} }
} else { } else {
\Froxlor\UI\Response::standard_error('ftp_cantdeletemainaccount'); standard_error('ftp_cantdeletemainaccount');
} }
} elseif ($action == 'add') { } elseif ($action == 'add') {
if ($userinfo['ftps_used'] < $userinfo['ftps'] || $userinfo['ftps'] == '-1') { if ($userinfo['ftps_used'] < $userinfo['ftps'] || $userinfo['ftps'] == '-1') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send'])
try { && $_POST['send'] == 'send') {
Ftps::getLocal($userinfo, $_POST)->add(); $description = validate($_POST['ftp_description'], 'description');
} catch (Exception $e) { // @FIXME use a good path-validating regex here (refs #1231)
\Froxlor\UI\Response::dynamic_error($e->getMessage()); $path = validate($_POST['path'], 'path');
$password = validate($_POST['ftp_password'], 'password');
$password = validatePassword($password);
$shell = "/bin/false";
if (Settings::Get('system.allow_customer_shell') == '1') {
$shell = isset($_POST['shell']) ? validate($_POST['shell'], 'shell') : '/bin/false';
} }
\Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page, $sendinfomail = isset($_POST['sendinfomail']) ? 1 : 0;
's' => $s if ($sendinfomail != 1) {
)); $sendinfomail = 0;
}
if (Settings::Get('customer.ftpatdomain') == '1') {
$ftpusername = validate($_POST['ftp_username'], 'username', '/^[a-zA-Z0-9][a-zA-Z0-9\-_]+\$?$/');
if ($ftpusername == '') {
standard_error(array('stringisempty', 'username'));
}
$ftpdomain = $idna_convert->encode(validate($_POST['ftp_domain'], 'domain'));
$ftpdomain_check_stmt = Database::prepare("SELECT `id`, `domain`, `customerid` FROM `" . TABLE_PANEL_DOMAINS . "`
WHERE `domain` = :domain
AND `customerid` = :customerid"
);
Database::pexecute($ftpdomain_check_stmt, array("domain" => $ftpdomain, "customerid" => $userinfo['customerid']));
$ftpdomain_check = $ftpdomain_check_stmt->fetch(PDO::FETCH_ASSOC);
if ($ftpdomain_check['domain'] != $ftpdomain) {
standard_error('maindomainnonexist', $domain);
}
$username = $ftpusername . "@" . $ftpdomain;
} else { } else {
$pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], '/'); $username = $userinfo['loginname'] . Settings::Get('customer.ftpprefix') . (intval($userinfo['ftp_lastaccountnumber']) + 1);
}
$username_check_stmt = Database::prepare("SELECT * FROM `" . TABLE_FTP_USERS . "`
WHERE `username` = :username"
);
Database::pexecute($username_check_stmt, array("username" => $username));
$username_check = $username_check_stmt->fetch(PDO::FETCH_ASSOC);
if (!empty($username_check) && $username_check['username'] = $username) {
standard_error('usernamealreadyexists', $username);
} elseif ($password == '') {
standard_error(array('stringisempty', 'mypassword'));
} elseif ($path == '') {
standard_error('patherror');
} elseif ($username == $password) {
standard_error('passwordshouldnotbeusername');
} else {
$path = makeCorrectDir($userinfo['documentroot'] . '/' . $path);
$cryptPassword = makeCryptPassword($password);
$stmt = Database::prepare("INSERT INTO `" . TABLE_FTP_USERS . "`
(`customerid`, `username`, `description`, `password`, `homedir`, `login_enabled`, `uid`, `gid`, `shell`)
VALUES (:customerid, :username, :description, :password, :homedir, 'y', :guid, :guid, :shell)"
);
$params = array(
"customerid" => $userinfo['customerid'],
"username" => $username,
"description" => $description,
"password" => $cryptPassword,
"homedir" => $path,
"guid" => $userinfo['guid'],
"shell" => $shell
);
Database::pexecute($stmt, $params);
$result_stmt = Database::prepare("SELECT `bytes_in_used` FROM `" . TABLE_FTP_QUOTATALLIES . "`
WHERE `name` = :name"
);
Database::pexecute($result_stmt, array("name" => $userinfo['loginname']));
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$stmt = Database::prepare("INSERT INTO `" . TABLE_FTP_QUOTATALLIES . "`
(`name`, `quota_type`, `bytes_in_used`, `bytes_out_used`, `bytes_xfer_used`, `files_in_used`, `files_out_used`, `files_xfer_used`)
VALUES (:name, 'user', :bytes_in_used, '0', '0', '0', '0', '0')"
);
Database::pexecute($stmt, array("name" => $username, "bytes_in_used" => $row['bytes_in_used']));
}
$stmt = Database::prepare("UPDATE `" . TABLE_FTP_GROUPS . "`
SET `members` = CONCAT_WS(',',`members`, :username)
WHERE `customerid`= :customerid
AND `gid`= :guid"
);
$params = array(
"username" => $username,
"customerid" => $userinfo['customerid'],
"guid" => $userinfo['guid']
);
Database::pexecute($stmt, $params);
$stmt = Database::prepare("UPDATE `" . TABLE_PANEL_CUSTOMERS . "`
SET `ftps_used` = `ftps_used` + 1,
`ftp_lastaccountnumber` = `ftp_lastaccountnumber` + 1
WHERE `customerid` = :customerid"
);
Database::pexecute($stmt, array("customerid" => $userinfo['customerid']));
$log->logAction(USR_ACTION, LOG_INFO, "added ftp-account '" . $username . " (" . $path . ")'");
inserttask(5);
if ($sendinfomail == 1) {
$replace_arr = array(
'SALUTATION' => getCorrectUserSalutation($userinfo),
'CUST_NAME' => getCorrectUserSalutation($userinfo), // < keep this for compatibility
'USR_NAME' => $username,
'USR_PASS' => $password,
'USR_PATH' => makeCorrectDir(str_replace($userinfo['documentroot'], "/", $path))
);
$def_language = $userinfo['def_language'];
$result_stmt = Database::prepare("SELECT `value` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid
AND `language` = :lang
AND `templategroup`='mails'
AND `varname`='new_ftpaccount_by_customer_subject'"
);
Database::pexecute($result_stmt, array("adminid" => $userinfo['adminid'], "lang" => $def_language));
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
$mail_subject = html_entity_decode(replace_variables((($result['value'] != '') ? $result['value'] : $lng['mails']['new_ftpaccount_by_customer']['subject']), $replace_arr));
$def_language = $userinfo['def_language'];
$result_stmt = Database::prepare("SELECT `value` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid
AND `language` = :lang
AND `templategroup`='mails'
AND `varname`='new_ftpaccount_by_customer_mailbody'"
);
Database::pexecute($result_stmt, array("adminid" => $userinfo['adminid'], "lang" => $def_language));
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
$mail_body = html_entity_decode(replace_variables((($result['value'] != '') ? $result['value'] : $lng['mails']['new_ftpaccount_by_customer']['mailbody']), $replace_arr));
$_mailerror = false;
try {
$mail->Subject = $mail_subject;
$mail->AltBody = $mail_body;
$mail->MsgHTML(str_replace("\n", "<br />", $mail_body));
$mail->AddAddress($userinfo['email'], getCorrectUserSalutation($userinfo));
$mail->Send();
} catch(phpmailerException $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (Exception $e) {
$mailerr_msg = $e->getMessage();
$_mailerror = true;
}
if ($_mailerror) {
$log->logAction(USR_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg);
standard_error('errorsendingmail', $userinfo['email']);
}
$mail->ClearAddresses();
}
redirectTo($filename, array('page' => $page, 's' => $s));
}
} else {
$pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], '/');
if (Settings::Get('customer.ftpatdomain') == '1') { if (Settings::Get('customer.ftpatdomain') == '1') {
$domainlist = array(); $domainlist = array();
$domains = ''; $domains = '';
$result_domains_stmt = Database::prepare("SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "` $result_domains_stmt = Database::prepare("SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "`
WHERE `customerid`= :customerid"); WHERE `customerid`= :customerid"
Database::pexecute($result_domains_stmt, array( );
"customerid" => $userinfo['customerid'] Database::pexecute($result_domains_stmt, array("customerid" => $userinfo['customerid']));
));
while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) {
$domainlist[] = $row_domain['domain']; $domainlist[] = $row_domain['domain'];
@@ -143,98 +340,155 @@ if ($page == 'overview') {
if (isset($domainlist[0]) && $domainlist[0] != '') { if (isset($domainlist[0]) && $domainlist[0] != '') {
foreach ($domainlist as $dom) { foreach ($domainlist as $dom) {
$domains .= \Froxlor\UI\HTML::makeoption($idna_convert->decode($dom), $dom); $domains .= makeoption($idna_convert->decode($dom), $dom);
} }
} }
} }
if (Settings::Get('system.allow_customer_shell') == '1') { if (Settings::Get('system.allow_customer_shell') == '1') {
$shells = \Froxlor\UI\HTML::makeoption("/bin/false", "/bin/false", "/bin/false"); $shells = makeoption("/bin/false", "/bin/false", "/bin/false");
$shells_avail = Settings::Get('system.available_shells'); $shells_avail = Settings::Get('system.available_shells');
if (!empty($shells_avail)) { if (!empty($shells_avail)) {
$shells_avail = explode(",", $shells_avail); $shells_avail = explode(",", $shells_avail);
$shells_avail = array_map("trim", $shells_avail); $shells_avail = array_map("trim", $shells_avail);
foreach ($shells_avail as $_shell) { foreach ($shells_avail as $_shell) {
$shells .= \Froxlor\UI\HTML::makeoption($_shell, $_shell, "/bin/false"); $shells .= makeoption($_shell, $_shell, "/bin/false");
} }
} }
} }
// $sendinfomail = \Froxlor\UI\HTML::makeyesno('sendinfomail', '1', '0', '0'); //$sendinfomail = makeyesno('sendinfomail', '1', '0', '0');
$ftp_add_data = include_once dirname(__FILE__).'/lib/formfields/customer/ftp/formfield.ftp_add.php'; $ftp_add_data = include_once dirname(__FILE__).'/lib/formfields/customer/ftp/formfield.ftp_add.php';
$ftp_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($ftp_add_data); $ftp_add_form = htmlform::genHTMLForm($ftp_add_data);
$title = $ftp_add_data['ftp_add']['title']; $title = $ftp_add_data['ftp_add']['title'];
$image = $ftp_add_data['ftp_add']['image']; $image = $ftp_add_data['ftp_add']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate('ftp/accounts_add') . "\";"); eval("echo \"" . getTemplate('ftp/accounts_add') . "\";");
} }
} }
} elseif ($action == 'edit' && $id != 0) { } elseif ($action == 'edit' && $id != 0) {
try { $result_stmt = Database::prepare("SELECT `id`, `username`, `description`, `homedir`, `uid`, `gid`, `shell` FROM `" . TABLE_FTP_USERS . "`
$json_result = Ftps::getLocal($userinfo, array( WHERE `customerid` = :customerid
'id' => $id AND `id` = :id"
))->get(); );
} catch (Exception $e) { Database::pexecute($result_stmt, array("customerid" => $userinfo['customerid'], "id" => $id));
\Froxlor\UI\Response::dynamic_error($e->getMessage()); $result = $result_stmt->fetch(PDO::FETCH_ASSOC);
}
$result = json_decode($json_result, true)['data'];
if (isset($result['username']) && $result['username'] != '') { if (isset($result['username']) && $result['username'] != '') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { // @FIXME use a good path-validating regex here (refs #1231)
Ftps::getLocal($userinfo, $_POST)->update(); $path = validate($_POST['path'], 'path');
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage()); $shell = "/bin/false";
if (Settings::Get('system.allow_customer_shell') == '1') {
$shell = isset($_POST['shell']) ? validate($_POST['shell'], 'shell') : '/bin/false';
} }
\Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page, $_setnewpass = false;
's' => $s if (isset($_POST['ftp_password']) && $_POST['ftp_password'] != '') {
)); $password = validate($_POST['ftp_password'], 'password');
$password = validatePassword($password);
$_setnewpass = true;
}
if ($_setnewpass) {
if ($password == '') {
standard_error(array('stringisempty', 'mypassword'));
} elseif ($result['username'] == $password) {
standard_error('passwordshouldnotbeusername');
}
$log->logAction(USR_ACTION, LOG_INFO, "updated ftp-account password for '" . $result['username'] . "'");
$cryptPassword = makeCryptPassword($password);
$stmt = Database::prepare("UPDATE `" . TABLE_FTP_USERS . "`
SET `password` = :password
WHERE `customerid` = :customerid
AND `id` = :id"
);
Database::pexecute($stmt, array("customerid" => $userinfo['customerid'], "id" => $id, "password" => $cryptPassword));
}
if ($path != '') {
$path = makeCorrectDir($userinfo['documentroot'] . '/' . $path);
if ($path != $result['homedir']) {
if (!file_exists($path)) {
// it's the task for "new ftp" but that will
// create all directories and correct their permissions
inserttask(5);
}
$log->logAction(USR_ACTION, LOG_INFO, "updated ftp-account homdir for '" . $result['username'] . "'");
$stmt = Database::prepare("UPDATE `" . TABLE_FTP_USERS . "`
SET `homedir` = :homedir
WHERE `customerid` = :customerid
AND `id` = :id"
);
$params = array(
"homedir" => $path,
"customerid" => $userinfo['customerid'],
"id" => $id
);
Database::pexecute($stmt, $params);
}
}
$log->logAction(USR_ACTION, LOG_INFO, "edited ftp-account '" . $result['username'] . "'");
inserttask(5);
$description = validate($_POST['ftp_description'], 'description');
$stmt = Database::prepare("UPDATE `" . TABLE_FTP_USERS . "`
SET `description` = :desc, `shell` = :shell
WHERE `customerid` = :customerid
AND `id` = :id"
);
Database::pexecute($stmt, array("desc" => $description, "shell" => $shell, "customerid" => $userinfo['customerid'], "id" => $id));
redirectTo($filename, array('page' => $page, 's' => $s));
} else { } else {
if (strpos($result['homedir'], $userinfo['documentroot']) === 0) { if (strpos($result['homedir'], $userinfo['documentroot']) === 0) {
$homedir = str_replace($userinfo['documentroot'], "/", $result['homedir']); $homedir = str_replace($userinfo['documentroot'], "/", $result['homedir']);
} else { } else {
$homedir = $result['homedir']; $homedir = $result['homedir'];
} }
$homedir = \Froxlor\FileDir::makeCorrectDir($homedir); $homedir = makeCorrectDir($homedir);
$pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $homedir); $pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $homedir);
if (Settings::Get('customer.ftpatdomain') == '1') { if (Settings::Get('customer.ftpatdomain') == '1') {
$domains = ''; $domains = '';
$result_domains_stmt = Database::prepare("SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "` $result_domains_stmt = Database::prepare("SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "`
WHERE `customerid` = :customerid"); WHERE `customerid` = :customerid"
Database::pexecute($result_domains_stmt, array( );
"customerid" => $userinfo['customerid'] Database::pexecute($result_domains_stmt, array("customerid" => $userinfo['customerid']));
));
while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) { while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) {
$domains .= \Froxlor\UI\HTML::makeoption($idna_convert->decode($row_domain['domain']), $row_domain['domain']); $domains .= makeoption($idna_convert->decode($row_domain['domain']), $row_domain['domain']);
} }
} }
if (Settings::Get('system.allow_customer_shell') == '1') { if (Settings::Get('system.allow_customer_shell') == '1') {
$shells = \Froxlor\UI\HTML::makeoption("/bin/false", "/bin/false", $result['shell']); $shells = makeoption("/bin/false", "/bin/false", $result['shell']);
$shells_avail = Settings::Get('system.available_shells'); $shells_avail = Settings::Get('system.available_shells');
if (!empty($shells_avail)) { if (!empty($shells_avail)) {
$shells_avail = explode(",", $shells_avail); $shells_avail = explode(",", $shells_avail);
$shells_avail = array_map("trim", $shells_avail); $shells_avail = array_map("trim", $shells_avail);
foreach ($shells_avail as $_shell) { foreach ($shells_avail as $_shell) {
$shells .= \Froxlor\UI\HTML::makeoption($_shell, $_shell, $result['shell']); $shells .= makeoption($_shell, $_shell, $result['shell']);
} }
} }
} }
$ftp_edit_data = include_once dirname(__FILE__).'/lib/formfields/customer/ftp/formfield.ftp_edit.php'; $ftp_edit_data = include_once dirname(__FILE__).'/lib/formfields/customer/ftp/formfield.ftp_edit.php';
$ftp_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($ftp_edit_data); $ftp_edit_form = htmlform::genHTMLForm($ftp_edit_data);
$title = $ftp_edit_data['ftp_edit']['title']; $title = $ftp_edit_data['ftp_edit']['title'];
$image = $ftp_edit_data['ftp_edit']['image']; $image = $ftp_edit_data['ftp_edit']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate('ftp/accounts_edit') . "\";"); eval("echo \"" . getTemplate('ftp/accounts_edit') . "\";");
} }
} }
} }

View File

@@ -16,47 +16,41 @@
* @package Panel * @package Panel
* *
*/ */
define('AREA', 'customer'); define('AREA', 'customer');
require './lib/init.php'; require './lib/init.php';
use Froxlor\Database\Database;
use Froxlor\Settings;
use Froxlor\Api\Commands\Customers as Customers;
if ($action == 'logout') { if ($action == 'logout') {
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, 'logged out'); $log->logAction(USR_ACTION, LOG_NOTICE, 'logged out');
$params = array( $params = array("customerid" => $userinfo['customerid']);
"customerid" => $userinfo['customerid']
);
if (Settings::Get('session.allow_multiple_login') == '1') { if (Settings::Get('session.allow_multiple_login') == '1') {
$stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_SESSIONS . "` $stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_SESSIONS . "`
WHERE `userid` = :customerid WHERE `userid` = :customerid
AND `adminsession` = '0' AND `adminsession` = '0'
AND `hash` = :hash"); AND `hash` = :hash"
);
$params["hash"] = $s; $params["hash"] = $s;
} else { } else {
$stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_SESSIONS . "` $stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_SESSIONS . "`
WHERE `userid` = :customerid WHERE `userid` = :customerid
AND `adminsession` = '0'"); AND `adminsession` = '0'"
);
} }
Database::pexecute($stmt, $params); Database::pexecute($stmt, $params);
\Froxlor\UI\Response::redirectTo('index.php'); redirectTo('index.php');
} }
if ($page == 'overview') { if ($page == 'overview') {
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_index"); $log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_index");
$domain_stmt = Database::prepare("SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "` $domain_stmt = Database::prepare("SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "`
WHERE `customerid` = :customerid WHERE `customerid` = :customerid
AND `parentdomainid` = '0' AND `parentdomainid` = '0'
AND `id` <> :standardsubdomain AND `id` <> :standardsubdomain
"); ");
Database::pexecute($domain_stmt, array( Database::pexecute($domain_stmt, array("customerid" => $userinfo['customerid'], "standardsubdomain" => $userinfo['standardsubdomain']));
"customerid" => $userinfo['customerid'],
"standardsubdomain" => $userinfo['standardsubdomain']
));
$domains = ''; $domains = '';
$domainArray = array(); $domainArray = array();
@@ -76,10 +70,7 @@ if ($page == 'overview') {
WHERE `customerid` = :customerid WHERE `customerid` = :customerid
AND `id` = :standardsubdomain AND `id` = :standardsubdomain
"); ");
$std_domain = Database::pexecute_first($std_domain_stmt, array( $std_domain = Database::pexecute_first($std_domain_stmt, array("customerid" => $userinfo['customerid'], "standardsubdomain" => $userinfo['standardsubdomain']));
"customerid" => $userinfo['customerid'],
"standardsubdomain" => $userinfo['standardsubdomain']
));
$stdsubdomain = $std_domain['domain']; $stdsubdomain = $std_domain['domain'];
} }
@@ -89,162 +80,123 @@ if ($page == 'overview') {
// get disk-space usages for web, mysql and mail // get disk-space usages for web, mysql and mail
$usages_stmt = Database::prepare("SELECT * FROM `".TABLE_PANEL_DISKSPACE."` WHERE `customerid` = :cid ORDER BY `stamp` DESC LIMIT 1"); $usages_stmt = Database::prepare("SELECT * FROM `".TABLE_PANEL_DISKSPACE."` WHERE `customerid` = :cid ORDER BY `stamp` DESC LIMIT 1");
$usages = Database::pexecute_first($usages_stmt, array( $usages = Database::pexecute_first($usages_stmt, array('cid' => $userinfo['customerid']));
'cid' => $userinfo['customerid']
));
// get everything in bytes for the percentage calculation on the dashboard $userinfo['diskspace'] = round($userinfo['diskspace'] / 1024, Settings::Get('panel.decimal_places'));
$userinfo['diskspace_bytes'] = ($userinfo['diskspace'] > -1) ? $userinfo['diskspace'] * 1024 : -1; $userinfo['diskspace_used'] = round($usages['webspace'] / 1024, Settings::Get('panel.decimal_places'));
$userinfo['traffic_bytes'] = ($userinfo['traffic'] > -1) ? $userinfo['traffic'] * 1024 : - 1; $userinfo['mailspace_used'] = round($usages['mail'] / 1024, Settings::Get('panel.decimal_places'));
$userinfo['traffic_bytes_used'] = $userinfo['traffic_used'] * 1024; $userinfo['dbspace_used'] = round($usages['mysql'] / 1024, Settings::Get('panel.decimal_places'));
if ($usages) { $userinfo['traffic'] = round($userinfo['traffic'] / (1024 * 1024), Settings::Get('panel.decimal_places'));
$userinfo['diskspace_used'] = \Froxlor\PhpHelper::sizeReadable($usages['webspace'] * 1024, null, 'bi'); $userinfo['traffic_used'] = round($userinfo['traffic_used'] / (1024 * 1024), Settings::Get('panel.decimal_places'));
$userinfo['mailspace_used'] = \Froxlor\PhpHelper::sizeReadable($usages['mail'] * 1024, null, 'bi'); $userinfo = str_replace_array('-1', $lng['customer']['unlimited'], $userinfo, 'diskspace traffic mysqls emails email_accounts email_forwarders email_quota ftps tickets subdomains');
$userinfo['dbspace_used'] = \Froxlor\PhpHelper::sizeReadable($usages['mysql'] * 1024, null, 'bi');
$userinfo['total_used'] = \Froxlor\PhpHelper::sizeReadable(($usages['webspace'] + $usages['mail'] + $usages['mysql']) * 1024, null, 'bi');
$userinfo['diskspace_bytes_used'] = $usages['webspace'] * 1024;
$userinfo['total_bytes_used'] = ($usages['webspace'] + $usages['mail'] + $usages['mysql']) * 1024;
} else {
$userinfo['diskspace_used'] = 0;
$userinfo['mailspace_used'] = 0;
$userinfo['dbspace_used'] = 0;
$userinfo['total_used'] = 0;
$userinfo['diskspace_bytes_used'] = 0;
$userinfo['total_bytes_used'] = 0;
}
$userinfo['diskspace'] = ($userinfo['diskspace'] > -1) ? \Froxlor\PhpHelper::sizeReadable($userinfo['diskspace'] * 1024, null, 'bi') : - 1;
$userinfo['traffic'] = ($userinfo['traffic'] > -1) ? \Froxlor\PhpHelper::sizeReadable($userinfo['traffic'] * 1024, null, 'bi') : - 1;
$userinfo['traffic_used'] = \Froxlor\PhpHelper::sizeReadable($userinfo['traffic_used'] * 1024, null, 'bi');
$userinfo = \Froxlor\PhpHelper::strReplaceArray('-1', $lng['customer']['unlimited'], $userinfo, 'diskspace diskspace_bytes traffic traffic_bytes mysqls emails email_accounts email_forwarders email_quota ftps subdomains');
$userinfo['custom_notes'] = ($userinfo['custom_notes'] != '') ? nl2br($userinfo['custom_notes']) : ''; $userinfo['custom_notes'] = ($userinfo['custom_notes'] != '') ? nl2br($userinfo['custom_notes']) : '';
$services_enabled = ""; $services_enabled = "";
$se = array(); $se = array();
if ($userinfo['imap'] == '1') if ($userinfo['imap'] == '1') $se[] = "IMAP";
$se[] = "IMAP"; if ($userinfo['pop3'] == '1') $se[] = "POP3";
if ($userinfo['pop3'] == '1') if ($userinfo['phpenabled'] == '1') $se[] = "PHP";
$se[] = "POP3"; if ($userinfo['perlenabled'] == '1') $se[] = "Perl/CGI";
if ($userinfo['phpenabled'] == '1')
$se[] = "PHP";
if ($userinfo['perlenabled'] == '1')
$se[] = "Perl/CGI";
if ($userinfo['api_allowed'] == '1')
$se[] = '<a href="customer_index.php?s=' . $s . '&page=apikeys">API</a>';
$services_enabled = implode(", ", $se); $services_enabled = implode(", ", $se);
eval("echo \"" . \Froxlor\UI\Template::getTemplate('index/index') . "\";"); eval("echo \"" . getTemplate('index/index') . "\";");
} elseif ($page == 'change_password') { } elseif ($page == 'change_password') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
$old_password = \Froxlor\Validate\Validate::validate($_POST['old_password'], 'old password'); $old_password = validate($_POST['old_password'], 'old password');
if (!validatePasswordLogin($userinfo,$old_password,TABLE_PANEL_CUSTOMERS,'customerid')) {
if (! \Froxlor\System\Crypt::validatePasswordLogin($userinfo, $old_password, TABLE_PANEL_CUSTOMERS, 'customerid')) { standard_error('oldpasswordnotcorrect');
\Froxlor\UI\Response::standard_error('oldpasswordnotcorrect');
} }
try { $new_password = validatePassword($_POST['new_password'], 'new password');
$new_password = \Froxlor\System\Crypt::validatePassword($_POST['new_password'], 'new password'); $new_password_confirm = validatePassword($_POST['new_password_confirm'], 'new password confirm');
$new_password_confirm = \Froxlor\System\Crypt::validatePassword($_POST['new_password_confirm'], 'new password confirm');
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
if ($old_password == '') { if ($old_password == '') {
\Froxlor\UI\Response::standard_error(array( standard_error(array('stringisempty', 'oldpassword'));
'stringisempty',
'oldpassword'
));
} elseif ($new_password == '') { } elseif ($new_password == '') {
\Froxlor\UI\Response::standard_error(array( standard_error(array('stringisempty', 'newpassword'));
'stringisempty',
'newpassword'
));
} elseif ($new_password_confirm == '') { } elseif ($new_password_confirm == '') {
\Froxlor\UI\Response::standard_error(array( standard_error(array('stringisempty', 'newpasswordconfirm'));
'stringisempty',
'newpasswordconfirm'
));
} elseif ($new_password != $new_password_confirm) { } elseif ($new_password != $new_password_confirm) {
\Froxlor\UI\Response::standard_error('newpasswordconfirmerror'); standard_error('newpasswordconfirmerror');
} else { } else {
// Update user password // Update user password
try { $stmt = Database::prepare("UPDATE `" . TABLE_PANEL_CUSTOMERS . "`
Customers::getLocal($userinfo, array( SET `password` = :newpassword
'id' => $userinfo['customerid'], WHERE `customerid` = :customerid"
'new_customer_password' => $new_password );
))->update(); $params = array(
} catch (Exception $e) { "newpassword" => makeCryptPassword($new_password),
\Froxlor\UI\Response::dynamic_error($e->getMessage()); "customerid" => $userinfo['customerid']
} );
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, 'changed password'); Database::pexecute($stmt, $params);
$log->logAction(USR_ACTION, LOG_NOTICE, 'changed password');
// Update ftp password // Update ftp password
if (isset($_POST['change_main_ftp']) && $_POST['change_main_ftp'] == 'true') { if (isset($_POST['change_main_ftp']) && $_POST['change_main_ftp'] == 'true') {
$cryptPassword = \Froxlor\System\Crypt::makeCryptPassword($new_password); $cryptPassword = makeCryptPassword($new_password);
$stmt = Database::prepare("UPDATE `" . TABLE_FTP_USERS . "` $stmt = Database::prepare("UPDATE `" . TABLE_FTP_USERS . "`
SET `password` = :password SET `password` = :password
WHERE `customerid` = :customerid WHERE `customerid` = :customerid
AND `username` = :username"); AND `username` = :username"
);
$params = array( $params = array(
"password" => $cryptPassword, "password" => $cryptPassword,
"customerid" => $userinfo['customerid'], "customerid" => $userinfo['customerid'],
"username" => $userinfo['loginname'] "username" => $userinfo['loginname']
); );
Database::pexecute($stmt, $params); Database::pexecute($stmt, $params);
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, 'changed main ftp password'); $log->logAction(USR_ACTION, LOG_NOTICE, 'changed main ftp password');
} }
// Update statistics password // Update webalizer password
if (isset($_POST['change_stats']) && $_POST['change_stats'] == 'true') { if (isset($_POST['change_webalizer']) && $_POST['change_webalizer'] == 'true') {
$new_stats_password = \Froxlor\System\Crypt::makeCryptPassword($new_password, 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);
}
$stmt = Database::prepare("UPDATE `" . TABLE_PANEL_HTPASSWDS . "` $stmt = Database::prepare("UPDATE `" . TABLE_PANEL_HTPASSWDS . "`
SET `password` = :password SET `password` = :password
WHERE `customerid` = :customerid WHERE `customerid` = :customerid
AND `username` = :username"); AND `username` = :username"
);
$params = array( $params = array(
"password" => $new_stats_password, "password" => $new_webalizer_password,
"customerid" => $userinfo['customerid'], "customerid" => $userinfo['customerid'],
"username" => $userinfo['loginname'] "username" => $userinfo['loginname']
); );
Database::pexecute($stmt, $params); Database::pexecute($stmt, $params);
} }
\Froxlor\UI\Response::redirectTo($filename, array( redirectTo($filename, array('s' => $s));
's' => $s
));
} }
} else { } else {
eval("echo \"" . \Froxlor\UI\Template::getTemplate('index/change_password') . "\";"); eval("echo \"" . getTemplate('index/change_password') . "\";");
} }
} elseif ($page == 'change_language') { } elseif ($page == 'change_language') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
$def_language = \Froxlor\Validate\Validate::validate($_POST['def_language'], 'default language'); $def_language = validate($_POST['def_language'], 'default language');
if (isset($languages[$def_language])) { if (isset($languages[$def_language])) {
try { $stmt = Database::prepare("UPDATE `" . TABLE_PANEL_CUSTOMERS . "`
Customers::getLocal($userinfo, array( SET `def_language` = :lang
'id' => $userinfo['customerid'], WHERE `customerid` = :customerid"
'def_language' => $def_language );
))->update(); Database::pexecute($stmt, array("lang" => $def_language, "customerid" => $userinfo['customerid']));
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
// also update current session
$stmt = Database::prepare("UPDATE `" . TABLE_PANEL_SESSIONS . "` $stmt = Database::prepare("UPDATE `" . TABLE_PANEL_SESSIONS . "`
SET `language` = :lang SET `language` = :lang
WHERE `hash` = :hash"); WHERE `hash` = :hash"
Database::pexecute($stmt, array( );
"lang" => $def_language, Database::pexecute($stmt, array("lang" => $def_language, "hash" => $s));
"hash" => $s
)); $log->logAction(USR_ACTION, LOG_NOTICE, "changed default language to '" . $def_language . "'");
} }
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "changed default language to '" . $def_language . "'");
\Froxlor\UI\Response::redirectTo($filename, array( redirectTo($filename, array('s' => $s));
's' => $s
));
} else { } else {
$default_lang = Settings::Get('panel.standardlanguage'); $default_lang = Settings::Get('panel.standardlanguage');
if ($userinfo['def_language'] != '') { if ($userinfo['def_language'] != '') {
@@ -253,36 +205,29 @@ if ($page == 'overview') {
$language_options = ''; $language_options = '';
foreach ($languages as $language_file => $language_name) { foreach ($languages as $language_file => $language_name) {
$language_options .= \Froxlor\UI\HTML::makeoption($language_name, $language_file, $default_lang, true); $language_options .= makeoption($language_name, $language_file, $default_lang, true);
} }
eval("echo \"" . \Froxlor\UI\Template::getTemplate('index/change_language') . "\";"); eval("echo \"" . getTemplate('index/change_language') . "\";");
} }
} elseif ($page == 'change_theme') { } elseif ($page == 'change_theme') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
$theme = \Froxlor\Validate\Validate::validate($_POST['theme'], 'theme'); $theme = validate($_POST['theme'], 'theme');
try {
Customers::getLocal($userinfo, array( $stmt = Database::prepare("UPDATE `" . TABLE_PANEL_CUSTOMERS . "`
'id' => $userinfo['customerid'], SET `theme` = :theme
'theme' => $theme WHERE `customerid` = :customerid"
))->update(); );
} catch (Exception $e) { Database::pexecute($stmt, array("theme" => $theme, "customerid" => $userinfo['customerid']));
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
// also update current session
$stmt = Database::prepare("UPDATE `" . TABLE_PANEL_SESSIONS . "` $stmt = Database::prepare("UPDATE `" . TABLE_PANEL_SESSIONS . "`
SET `theme` = :theme SET `theme` = :theme
WHERE `hash` = :hash"); WHERE `hash` = :hash"
Database::pexecute($stmt, array( );
"theme" => $theme, Database::pexecute($stmt, array("theme" => $theme, "hash" => $s));
"hash" => $s
));
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "changed default theme to '" . $theme . "'"); $log->logAction(USR_ACTION, LOG_NOTICE, "changed default theme to '" . $theme . "'");
\Froxlor\UI\Response::redirectTo($filename, array( redirectTo($filename, array('s' => $s));
's' => $s
));
} else { } else {
$default_theme = Settings::Get('panel.default_theme'); $default_theme = Settings::Get('panel.default_theme');
if ($userinfo['theme'] != '') { if ($userinfo['theme'] != '') {
@@ -290,13 +235,14 @@ if ($page == 'overview') {
} }
$theme_options = ''; $theme_options = '';
$themes_avail = \Froxlor\UI\Template::getThemes(); $themes_avail = getThemes();
foreach ($themes_avail as $t => $d) { foreach ($themes_avail as $t => $d) {
$theme_options .= \Froxlor\UI\HTML::makeoption($d, $t, $default_theme, true); $theme_options.= makeoption($d, $t, $default_theme, true);
} }
eval("echo \"" . \Froxlor\UI\Template::getTemplate('index/change_theme') . "\";"); eval("echo \"" . getTemplate('index/change_theme') . "\";");
} }
} elseif ($page == 'send_error_report' && Settings::Get('system.allow_error_report_customer') == '1') { } elseif ($page == 'send_error_report' && Settings::Get('system.allow_error_report_customer') == '1') {
// only show this if we really have an exception to report // only show this if we really have an exception to report
@@ -304,8 +250,8 @@ if ($page == 'overview') {
$errid = $_GET['errorid']; $errid = $_GET['errorid'];
// read error file // read error file
$err_dir = \Froxlor\FileDir::makeCorrectDir(\Froxlor\Froxlor::getInstallDir() . "/logs/"); $err_dir = makeCorrectDir(FROXLOR_INSTALL_DIR."/logs/");
$err_file = \Froxlor\FileDir::makeCorrectFile($err_dir . "/" . $errid . "_sql-error.log"); $err_file = makeCorrectFile($err_dir."/".$errid."_sql-error.log");
if (file_exists($err_file)) { if (file_exists($err_file)) {
@@ -315,9 +261,9 @@ if ($page == 'overview') {
$_error = array( $_error = array(
'code' => str_replace("\n", "", substr($error[1], 5)), 'code' => str_replace("\n", "", substr($error[1], 5)),
'message' => str_replace("\n", "", substr($error[2], 4)), 'message' => str_replace("\n", "", substr($error[2], 4)),
'file' => str_replace("\n", "", substr($error[3], 5 + strlen(\Froxlor\Froxlor::getInstallDir()))), 'file' => str_replace("\n", "", substr($error[3], 5 + strlen(FROXLOR_INSTALL_DIR))),
'line' => str_replace("\n", "", substr($error[4], 5)), 'line' => str_replace("\n", "", substr($error[4], 5)),
'trace' => str_replace(\Froxlor\Froxlor::getInstallDir(), "", substr($error[5], 6)) 'trace' => str_replace(FROXLOR_INSTALL_DIR, "", substr($error[5], 6))
); );
// build mail-content // build mail-content
@@ -334,7 +280,9 @@ if ($page == 'overview') {
$mail_html = str_replace("\n", "<br />", $mail_body); $mail_html = str_replace("\n", "<br />", $mail_body);
// send actual report to dev-team // send actual report to dev-team
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send'])
&& $_POST['send'] == 'send'
) {
// send mail and say thanks // send mail and say thanks
$_mailerror = false; $_mailerror = false;
try { try {
@@ -343,7 +291,7 @@ if ($page == 'overview') {
$mail->MsgHTML($mail_html); $mail->MsgHTML($mail_html);
$mail->AddAddress('error-reports@froxlor.org', 'Froxlor Developer Team'); $mail->AddAddress('error-reports@froxlor.org', 'Froxlor Developer Team');
$mail->Send(); $mail->Send();
} catch (\PHPMailer\PHPMailer\Exception $e) { } catch(phpmailerException $e) {
$mailerr_msg = $e->errorMessage(); $mailerr_msg = $e->errorMessage();
$_mailerror = true; $_mailerror = true;
} catch (Exception $e) { } catch (Exception $e) {
@@ -353,30 +301,21 @@ if ($page == 'overview') {
if ($_mailerror) { if ($_mailerror) {
// error when reporting an error...LOLFUQ // error when reporting an error...LOLFUQ
\Froxlor\UI\Response::standard_error('send_report_error', $mailerr_msg); standard_error('send_report_error', $mailerr_msg);
} }
// finally remove error from fs // finally remove error from fs
@unlink($err_file); @unlink($err_file);
\Froxlor\UI\Response::redirectTo($filename, array( redirectTo($filename, array('s' => $s));
's' => $s
));
} }
// show a nice summary of the error-report // show a nice summary of the error-report
// before actually sending anything // before actually sending anything
eval("echo \"" . \Froxlor\UI\Template::getTemplate("index/send_error_report") . "\";"); eval("echo \"" . getTemplate("index/send_error_report") . "\";");
} else { } else {
\Froxlor\UI\Response::redirectTo($filename, array( redirectTo($filename, array('s' => $s));
's' => $s
));
} }
} else { } else {
\Froxlor\UI\Response::redirectTo($filename, array( redirectTo($filename, array('s' => $s));
's' => $s
));
} }
} 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';
} }

View File

@@ -19,13 +19,9 @@
define('AREA', 'customer'); define('AREA', 'customer');
require './lib/init.php'; require './lib/init.php';
use Froxlor\Api\Commands\SysLog;
use Froxlor\Database\Database;
use Froxlor\Settings;
// redirect if this customer page is hidden via settings // redirect if this customer page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options', 'extras.logger')) { if (Settings::IsInList('panel.customer_hide_options', 'extras.logger')) {
\Froxlor\UI\Response::redirectTo('customer_index.php'); redirectTo('customer_index.php');
} }
if ($page == 'log') { if ($page == 'log') {
@@ -36,25 +32,26 @@ if ($page == 'log') {
'user' => $lng['logger']['user'], 'user' => $lng['logger']['user'],
'text' => $lng['logger']['action'] 'text' => $lng['logger']['action']
); );
try { $paging = new paging($userinfo, TABLE_PANEL_LOG, $fields, null, null, 0, 'desc', 30);
// get total count $query = 'SELECT * FROM `' . TABLE_PANEL_LOG . '` WHERE `user` = :loginname ' . $paging->getSqlWhere(true) . ' ' . $paging->getSqlOrderBy();
$json_result = SysLog::getLocal($userinfo)->listingCount(); $result_stmt = Database::prepare($query . ' ' . $paging->getSqlLimit());
$result = json_decode($json_result, true)['data']; Database::pexecute($result_stmt, array(
// initialize pagination and filtering "loginname" => $userinfo['loginname']
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result); ));
// get list $result_cnt_stmt = Database::prepare($query);
$json_result = SysLog::getLocal($userinfo, $paging->getApiCommandParams())->listing(); Database::pexecute($result_cnt_stmt, array(
} catch (Exception $e) { "loginname" => $userinfo['loginname']
\Froxlor\UI\Response::dynamic_error($e->getMessage()); ));
} $res_cnt = $result_cnt_stmt->fetch(PDO::FETCH_ASSOC);
$result = json_decode($json_result, true)['data']; $logs_count = $result_cnt_stmt->rowCount();
$paging->setEntries($logs_count);
$sortcode = $paging->getHtmlSortCode($lng); $sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s); $arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng); $searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s); $pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$clog = array(); $clog = array();
foreach ($result['list'] as $row) { while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
if (! isset($clog[$row['action']]) || ! is_array($clog[$row['action']])) { if (! isset($clog[$row['action']]) || ! is_array($clog[$row['action']])) {
$clog[$row['action']] = array(); $clog[$row['action']] = array();
@@ -68,6 +65,7 @@ if ($page == 'log') {
ksort($clog); ksort($clog);
} }
$i = 0;
$count = 0; $count = 0;
$log_count = 0; $log_count = 0;
$log = ''; $log = '';
@@ -75,27 +73,27 @@ if ($page == 'log') {
$_action = 0; $_action = 0;
foreach ($logrows as $row) { foreach ($logrows as $row) {
// if ($paging->checkDisplay($i)) { // if ($paging->checkDisplay($i)) {
$row = \Froxlor\PhpHelper::htmlentitiesArray($row); $row = htmlentities_array($row);
$row['date'] = date("d.m.y H:i:s", $row['date']); $row['date'] = date("d.m.y H:i:s", $row['date']);
if ($_action != $action) { if ($_action != $action) {
switch ($action) { switch ($action) {
case \Froxlor\FroxlorLogger::USR_ACTION: case USR_ACTION:
$_action = $lng['admin']['customer']; $_action = $lng['admin']['customer'];
break; break;
case \Froxlor\FroxlorLogger::RES_ACTION: case RES_ACTION:
$_action = $lng['logger']['reseller']; $_action = $lng['logger']['reseller'];
break; break;
case \Froxlor\FroxlorLogger::ADM_ACTION: case ADM_ACTION:
$_action = $lng['logger']['admin']; $_action = $lng['logger']['admin'];
break; break;
case \Froxlor\FroxlorLogger::CRON_ACTION: case CRON_ACTION:
$_action = $lng['logger']['cron']; $_action = $lng['logger']['cron'];
break; break;
case \Froxlor\FroxlorLogger::LOGIN_ACTION: case LOGIN_ACTION:
$_action = $lng['logger']['login']; $_action = $lng['logger']['login'];
break; break;
case \Froxlor\FroxlorLogger::LOG_ERROR: case LOG_ERROR:
$_action = $lng['logger']['intern']; $_action = $lng['logger']['intern'];
break; break;
default: default:
@@ -104,17 +102,20 @@ if ($page == 'log') {
} }
$row['action'] = $_action; $row['action'] = $_action;
eval("\$log.=\"" . \Froxlor\UI\Template::getTemplate('logger/logger_action') . "\";"); eval("\$log.=\"" . getTemplate('logger/logger_action') . "\";");
} }
$log_count ++; $log_count ++;
$row['type'] = \Froxlor\FroxlorLogger::getInstanceOf()->getLogLevelDesc($row['type']); $row['type'] = getLogLevelDesc($row['type']);
eval("\$log.=\"" . \Froxlor\UI\Template::getTemplate('logger/logger_log') . "\";"); eval("\$log.=\"" . getTemplate('logger/logger_log') . "\";");
$count ++; $count ++;
$_action = $action; $_action = $action;
// }
$i ++;
} }
$i ++;
} }
eval("echo \"" . \Froxlor\UI\Template::getTemplate('logger/logger') . "\";"); eval("echo \"" . getTemplate('logger/logger') . "\";");
} }
} }

View File

@@ -16,16 +16,13 @@
* @package Panel * @package Panel
* *
*/ */
define('AREA', 'customer'); define('AREA', 'customer');
require './lib/init.php'; require './lib/init.php';
use Froxlor\Database\Database;
use Froxlor\Settings;
use Froxlor\Api\Commands\Mysqls as Mysqls;
// redirect if this customer page is hidden via settings // redirect if this customer page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options','mysql')) { if (Settings::IsInList('panel.customer_hide_options','mysql')) {
\Froxlor\UI\Response::redirectTo('customer_index.php'); redirectTo('customer_index.php');
} }
// get sql-root access data // get sql-root access data
@@ -41,36 +38,31 @@ if (isset($_POST['id'])) {
} }
if ($page == 'overview') { if ($page == 'overview') {
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_mysql"); $log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_mysql");
Database::needSqlData(); Database::needSqlData();
$sql = Database::getSqlData(); $sql = Database::getSqlData();
$lng['mysql']['description'] = str_replace('<SQL_HOST>', $sql['host'], $lng['mysql']['description']); $lng['mysql']['description'] = str_replace('<SQL_HOST>', $sql['host'], $lng['mysql']['description']);
eval("echo \"" . \Froxlor\UI\Template::getTemplate('mysql/mysql') . "\";"); eval("echo \"" . getTemplate('mysql/mysql') . "\";");
} elseif ($page == 'mysqls') { } elseif ($page == 'mysqls') {
if ($action == '') { if ($action == '') {
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_mysql::mysqls"); $log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_mysql::mysqls");
$fields = array( $fields = array(
'databasename' => $lng['mysql']['databasename'], 'databasename' => $lng['mysql']['databasename'],
'description' => $lng['mysql']['databasedescription'] 'description' => $lng['mysql']['databasedescription']
); );
try { $paging = new paging($userinfo, TABLE_PANEL_DATABASES, $fields);
// get total count $result_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_DATABASES . "`
$json_result = Mysqls::getLocal($userinfo)->listingCount(); WHERE `customerid`= :customerid " . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit()
$result = json_decode($json_result, true)['data']; );
// initialize pagination and filtering Database::pexecute($result_stmt, array("customerid" => $userinfo['customerid']));
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result); $mysqls_count = Database::num_rows();
// get list $paging->setEntries($mysqls_count);
$json_result = Mysqls::getLocal($userinfo, $paging->getApiCommandParams())->listing();
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$mysqls_count = $paging->getEntries();
$sortcode = $paging->getHtmlSortCode($lng); $sortcode = $paging->getHtmlSortCode($lng);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s); $arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng); $searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s); $pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$i = 0;
$count = 0; $count = 0;
$mysqls = ''; $mysqls = '';
@@ -80,35 +72,33 @@ if ($page == 'overview') {
// Begin root-session // Begin root-session
Database::needRoot(true); Database::needRoot(true);
foreach ($result['list'] as $row) { while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$row = \Froxlor\PhpHelper::htmlentitiesArray($row); if ($paging->checkDisplay($i)) {
$row = htmlentities_array($row);
$mbdata_stmt = Database::prepare("SELECT SUM(data_length + index_length) as MB FROM information_schema.TABLES $mbdata_stmt = Database::prepare("SELECT SUM(data_length + index_length) as MB FROM information_schema.TABLES
WHERE table_schema = :table_schema WHERE table_schema = :table_schema
GROUP BY table_schema"); GROUP BY table_schema"
$mbdata = Database::pexecute_first($mbdata_stmt, array( );
"table_schema" => $row['databasename'] Database::pexecute($mbdata_stmt, array("table_schema" => $row['databasename']));
)); $mbdata = $mbdata_stmt->fetch(PDO::FETCH_ASSOC);
if (!$mbdata) { $row['size'] = size_readable($mbdata['MB'], 'GiB', 'bi', '%01.' . (int)Settings::Get('panel.decimal_places') . 'f %s');
$mbdata = array('MB' => 0); eval("\$mysqls.=\"" . getTemplate('mysql/mysqls_database') . "\";");
}
$row['size'] = \Froxlor\PhpHelper::sizeReadable($mbdata['MB'], 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s');
eval("\$mysqls.=\"" . \Froxlor\UI\Template::getTemplate('mysql/mysqls_database') . "\";");
$count++; $count++;
} }
$i++;
}
Database::needRoot(false); Database::needRoot(false);
// End root-session // End root-session
eval("echo \"" . \Froxlor\UI\Template::getTemplate('mysql/mysqls') . "\";"); eval("echo \"" . getTemplate('mysql/mysqls') . "\";");
} elseif ($action == 'delete' && $id != 0) {
try { } elseif ($action == 'delete' && $id != 0) {
$json_result = Mysqls::getLocal($userinfo, array( $result_stmt = Database::prepare('SELECT `id`, `databasename`, `description`, `dbserver` FROM `' . TABLE_PANEL_DATABASES . '`
'id' => $id WHERE `customerid`="' . (int)$userinfo['customerid'] . '"
))->get(); AND `id`="' . (int)$id . '"'
} catch (Exception $e) { );
\Froxlor\UI\Response::dynamic_error($e->getMessage()); Database::pexecute($result_stmt, array("customerid" => $userinfo['customerid']));
} $result = $result_stmt->fetch(PDO::FETCH_ASSOC);
$result = json_decode($json_result, true)['data'];
if (isset($result['databasename']) && $result['databasename'] != '') { if (isset($result['databasename']) && $result['databasename'] != '') {
@@ -122,39 +112,168 @@ if ($page == 'overview') {
} }
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { // Begin root-session
Mysqls::getLocal($userinfo, $_POST)->delete(); Database::needRoot(true, $result['dbserver']);
} catch (Exception $e) { $dbm = new DbManager($log);
\Froxlor\UI\Response::dynamic_error($e->getMessage()); $dbm->getManager()->deleteDatabase($result['databasename']);
} $log->logAction(USR_ACTION, LOG_INFO, "deleted database '" . $result['databasename'] . "'");
\Froxlor\UI\Response::redirectTo($filename, array( Database::needRoot(false);
'page' => $page, // End root-session
's' => $s
)); $stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_DATABASES . "`
WHERE `customerid` = :customerid
AND `id` = :id"
);
Database::pexecute($stmt, array("customerid" => $userinfo['customerid'], "id" => $id));
$resetaccnumber = ($userinfo['mysqls_used'] == '1') ? " , `mysql_lastaccountnumber` = '0' " : '';
$stmt = Database::prepare("UPDATE `" . TABLE_PANEL_CUSTOMERS . "`
SET `mysqls_used` = `mysqls_used` - 1 " . $resetaccnumber . "
WHERE `customerid` = :customerid"
);
Database::pexecute($stmt, array("customerid" => $userinfo['customerid']));
redirectTo($filename, array('page' => $page, 's' => $s));
} else { } else {
$dbnamedesc = $result['databasename']; $dbnamedesc = $result['databasename'];
if (isset($result['description']) && $result['description'] != '') { if (isset($result['description']) && $result['description'] != '') {
$dbnamedesc .= ' ('.$result['description'].')'; $dbnamedesc .= ' ('.$result['description'].')';
} }
\Froxlor\UI\HTML::askYesNo('mysql_reallydelete', $filename, array( ask_yesno('mysql_reallydelete', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $dbnamedesc);
'id' => $id,
'page' => $page,
'action' => $action
), $dbnamedesc);
} }
} }
} elseif ($action == 'add') { } elseif ($action == 'add') {
if ($userinfo['mysqls_used'] < $userinfo['mysqls'] || $userinfo['mysqls'] == '-1') { if ($userinfo['mysqls_used'] < $userinfo['mysqls'] || $userinfo['mysqls'] == '-1') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { $password = validate($_POST['mysql_password'], 'password');
Mysqls::getLocal($userinfo, $_POST)->add(); $password = validatePassword($password);
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage()); $sendinfomail = isset($_POST['sendinfomail']) ? 1 : 0;
if ($sendinfomail != 1) {
$sendinfomail = 0;
}
if ($password == '') {
standard_error(array('stringisempty', 'mypassword'));
} else {
$dbserver = 0;
$dbservers_stmt = Database::query("SELECT COUNT(DISTINCT `dbserver`) as numservers FROM `".TABLE_PANEL_DATABASES."`");
$_dbserver = $dbservers_stmt->fetch(PDO::FETCH_ASSOC);
$count_mysqlservers = $_dbserver['numservers'];
if ($count_mysqlservers > 1) {
$dbserver = validate($_POST['mysql_server'], html_entity_decode($lng['mysql']['mysql_server']), '', '', 0);
Database::needRoot(true, $dbserver);
Database::needSqlData();
$sql_root = Database::getSqlData();
Database::needRoot(false);
if (!isset($sql_root) || !is_array($sql_root)) {
$dbserver = 0;
}
}
// validate description before actual adding the database, #1052
$databasedescription = validate(trim($_POST['description']), 'description');
// create database, user, set permissions, etc.pp.
$dbm = new DbManager($log);
$username = $dbm->createDatabase(
$userinfo['loginname'],
$password,
$userinfo['mysql_lastaccountnumber']
);
// we've checked against the password in dbm->createDatabase
if ($username == false) {
standard_error('passwordshouldnotbeusername');
}
// Statement modified for Database description -- PH 2004-11-29
$stmt = Database::prepare('INSERT INTO `' . TABLE_PANEL_DATABASES . '`
(`customerid`, `databasename`, `description`, `dbserver`)
VALUES (:customerid, :databasename, :description, :dbserver)'
);
$params = array(
"customerid" => $userinfo['customerid'],
"databasename" => $username,
"description" => $databasedescription,
"dbserver" => $dbserver
);
Database::pexecute($stmt, $params);
$stmt = Database::prepare('UPDATE `' . TABLE_PANEL_CUSTOMERS . '`
SET `mysqls_used` = `mysqls_used` + 1, `mysql_lastaccountnumber` = `mysql_lastaccountnumber` + 1
WHERE `customerid` = :customerid'
);
Database::pexecute($stmt, array("customerid" => $userinfo['customerid']));
if ($sendinfomail == 1) {
$pma = $lng['admin']['notgiven'];
if (Settings::Get('panel.phpmyadmin_url') != '') {
$pma = Settings::Get('panel.phpmyadmin_url');
}
Database::needRoot(true, $dbserver);
Database::needSqlData();
$sql_root = Database::getSqlData();
Database::needRoot(false);
$replace_arr = array(
'SALUTATION' => getCorrectUserSalutation($userinfo),
'CUST_NAME' => getCorrectUserSalutation($userinfo), // < keep this for compatibility
'DB_NAME' => $username,
'DB_PASS' => $password,
'DB_DESC' => $databasedescription,
'DB_SRV' => $sql_root['host'],
'PMA_URI' => $pma
);
$def_language = $userinfo['def_language'];
$result_stmt = Database::prepare("SELECT `value` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid
AND `language` = :lang
AND `templategroup`='mails'
AND `varname`='new_database_by_customer_subject'"
);
Database::pexecute($result_stmt, array("adminid" => $userinfo['adminid'], "lang" => $def_language));
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
$mail_subject = html_entity_decode(replace_variables((($result['value'] != '') ? $result['value'] : $lng['mails']['new_database_by_customer']['subject']), $replace_arr));
$result_stmt = Database::prepare("SELECT `value` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid`= :adminid
AND `language`= :lang
AND `templategroup` = 'mails'
AND `varname` = 'new_database_by_customer_mailbody'"
);
Database::pexecute($result_stmt, array("adminid" => $userinfo['adminid'], "lang" => $def_language));
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
$mail_body = html_entity_decode(replace_variables((($result['value'] != '') ? $result['value'] : $lng['mails']['new_database_by_customer']['mailbody']), $replace_arr));
$_mailerror = false;
try {
$mail->Subject = $mail_subject;
$mail->AltBody = $mail_body;
$mail->MsgHTML(str_replace("\n", "<br />", $mail_body));
$mail->AddAddress($userinfo['email'], getCorrectUserSalutation($userinfo));
$mail->Send();
} catch(phpmailerException $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (Exception $e) {
$mailerr_msg = $e->getMessage();
$_mailerror = true;
}
if ($_mailerror) {
$log->logAction(USR_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg);
standard_error('errorsendingmail', $userinfo['email']);
}
$mail->ClearAddresses();
}
redirectTo($filename, array('page' => $page, 's' => $s));
} }
\Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page,
's' => $s
));
} else { } else {
$dbservers_stmt = Database::query("SELECT DISTINCT `dbserver` FROM `".TABLE_PANEL_DATABASES."`"); $dbservers_stmt = Database::query("SELECT DISTINCT `dbserver` FROM `".TABLE_PANEL_DATABASES."`");
@@ -164,41 +283,72 @@ if ($page == 'overview') {
Database::needRoot(true, $dbserver['dbserver']); Database::needRoot(true, $dbserver['dbserver']);
Database::needSqlData(); Database::needSqlData();
$sql_root = Database::getSqlData(); $sql_root = Database::getSqlData();
$mysql_servers .= \Froxlor\UI\HTML::makeoption($sql_root['caption'], $dbserver['dbserver']); $mysql_servers .= makeoption($sql_root['caption'], $dbserver['dbserver']);
$count_mysqlservers++; $count_mysqlservers++;
} }
Database::needRoot(false); Database::needRoot(false);
$mysql_add_data = include_once dirname(__FILE__).'/lib/formfields/customer/mysql/formfield.mysql_add.php'; $mysql_add_data = include_once dirname(__FILE__).'/lib/formfields/customer/mysql/formfield.mysql_add.php';
$mysql_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($mysql_add_data); $mysql_add_form = htmlform::genHTMLForm($mysql_add_data);
$title = $mysql_add_data['mysql_add']['title']; $title = $mysql_add_data['mysql_add']['title'];
$image = $mysql_add_data['mysql_add']['image']; $image = $mysql_add_data['mysql_add']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate('mysql/mysqls_add') . "\";"); eval("echo \"" . getTemplate('mysql/mysqls_add') . "\";");
} }
} }
} elseif ($action == 'edit' && $id != 0) { } elseif ($action == 'edit' && $id != 0) {
try { $result_stmt = Database::prepare("SELECT `id`, `databasename`, `description`, `dbserver` FROM `" . TABLE_PANEL_DATABASES . "`
$json_result = Mysqls::getLocal($userinfo, array( WHERE `customerid` = :customerid
'id' => $id AND `id` = :id"
))->get(); );
} catch (Exception $e) { Database::pexecute($result_stmt, array("customerid" => $userinfo['customerid'], "id" => $id));
\Froxlor\UI\Response::dynamic_error($e->getMessage()); $result = $result_stmt->fetch(PDO::FETCH_ASSOC);
}
$result = json_decode($json_result, true)['data'];
if (isset($result['databasename']) && $result['databasename'] != '') { if (isset($result['databasename']) && $result['databasename'] != '') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (!isset($sql_root[$result['dbserver']]) || !is_array($sql_root[$result['dbserver']])) {
try { $result['dbserver'] = 0;
$json_result = Mysqls::getLocal($userinfo, $_POST)->update();
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
} }
\Froxlor\UI\Response::redirectTo($filename, array(
'page' => $page, if (isset($_POST['send']) && $_POST['send'] == 'send') {
's' => $s // Only change Password if it is set, do nothing if it is empty! -- PH 2004-11-29
)); $password = validate($_POST['mysql_password'], 'password');
if ($password != '') {
// validate password
$password = validatePassword($password);
if ($password == $result['databasename']) {
standard_error('passwordshouldnotbeusername');
}
// Begin root-session
Database::needRoot(true);
foreach (array_map('trim', explode(',', Settings::Get('system.mysql_access_host'))) as $mysql_access_host) {
$stmt = Database::prepare("SET PASSWORD FOR :dbname@:host = PASSWORD(:password)");
$params = array(
"dbname" => $result['databasename'],
"host" => $mysql_access_host,
"password" => $password
);
Database::pexecute($stmt, $params);
}
$stmt = Database::prepare("FLUSH PRIVILEGES");
Database::pexecute($stmt);
Database::needRoot(false);
// End root-session
}
// Update the Database description -- PH 2004-11-29
$log->logAction(USR_ACTION, LOG_INFO, "edited database '" . $result['databasename'] . "'");
$databasedescription = validate($_POST['description'], 'description');
$stmt = Database::prepare("UPDATE `" . TABLE_PANEL_DATABASES . "`
SET `description` = :desc
WHERE `customerid` = :customerid
AND `id` = :id"
);
Database::pexecute($stmt, array("desc" => $databasedescription, "customerid" => $userinfo['customerid'], "id" => $id));
redirectTo($filename, array('page' => $page, 's' => $s));
} else { } else {
$dbservers_stmt = Database::query("SELECT COUNT(DISTINCT `dbserver`) as numservers FROM `".TABLE_PANEL_DATABASES."`"); $dbservers_stmt = Database::query("SELECT COUNT(DISTINCT `dbserver`) as numservers FROM `".TABLE_PANEL_DATABASES."`");
@@ -211,12 +361,12 @@ if ($page == 'overview') {
Database::needRoot(false); Database::needRoot(false);
$mysql_edit_data = include_once dirname(__FILE__).'/lib/formfields/customer/mysql/formfield.mysql_edit.php'; $mysql_edit_data = include_once dirname(__FILE__).'/lib/formfields/customer/mysql/formfield.mysql_edit.php';
$mysql_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($mysql_edit_data); $mysql_edit_form = htmlform::genHTMLForm($mysql_edit_data);
$title = $mysql_edit_data['mysql_edit']['title']; $title = $mysql_edit_data['mysql_edit']['title'];
$image = $mysql_edit_data['mysql_edit']['image']; $image = $mysql_edit_data['mysql_edit']['image'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate('mysql/mysqls_edit') . "\";"); eval("echo \"" . getTemplate('mysql/mysqls_edit') . "\";");
} }
} }
} }

411
customer_tickets.php Normal file
View File

@@ -0,0 +1,411 @@
<?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
*
*/
define('AREA', 'customer');
require './lib/init.php';
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
//Check if the current user is allowed to see the current ticket.
$stmt = Database::prepare("SELECT `id` FROM `panel_tickets` WHERE `id` = :id AND `customerid` = :customerid");
$result = Database::pexecute_first($stmt, array("id" => $id, "customerid" => $userinfo['customerid']));
if ($result == null) {
// no rights to see the requested ticket
standard_error(array('ticketnotaccessible'));
}
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
if ($page == 'overview') {
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_tickets");
eval("echo \"" . getTemplate("tickets/ticket") . "\";");
} elseif ($page == 'tickets') {
if ($action == '') {
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_tickets::tickets");
$fields = array(
'status' => $lng['ticket']['status'],
'lastchange' => $lng['ticket']['lastchange'],
'subject' => $lng['ticket']['subject'],
'lastreplier' => $lng['ticket']['lastreplier']
);
$paging = new paging($userinfo, TABLE_PANEL_TICKETS, $fields);
$stmt = Database::prepare('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`= :customerid ' . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit()
);
Database::pexecute($stmt, array("customerid" => $userinfo['customerid']));
$paging->setEntries(Database::num_rows());
$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 = $stmt->fetch(PDO::FETCH_ASSOC)) {
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;
}
$row['subject'] = html_entity_decode($row['subject']);
if (strlen($row['subject']) > 30) {
$ts = wordwrap($row['subject'], 30, "|");
$ts = explode("|", $ts);
$row['subject'] = $ts[0]. '...';
}
eval("\$tickets.=\"" . getTemplate("tickets/tickets_tickets") . "\";");
$count++;
}
$i++;
}
$supportavailable = 0;
$time = date("Hi", time());
$day = date("w", time());
$start = substr(Settings::Get('ticket.worktime_begin'), 0, 2) . substr(Settings::Get('ticket.worktime_begin'), 3, 2);
$end = substr(Settings::Get('ticket.worktime_end'), 0, 2) . substr(Settings::Get('ticket.worktime_end'), 3, 2);
if ($time >= $start && $time <= $end) {
$supportavailable = 1;
}
if (Settings::Get('ticket.worktime_sat') == "0" && $day == "6") {
$supportavailable = 0;
}
if (Settings::Get('ticket.worktime_sun') == "0" && $day == "0") {
$supportavailable = 0;
}
if (Settings::Get('ticket.worktime_all') == "1") {
$supportavailable = 1;
}
$ticketsopen = 0;
$stmt = Database::prepare('SELECT COUNT(`id`) as `count` FROM `' . TABLE_PANEL_TICKETS . '`
WHERE `customerid` = :customerid
AND `answerto` = "0"
AND (`status` = "0" OR `status` = "1" OR `status` = "2")'
);
$opentickets = Database::pexecute_first($stmt, array("customerid" => $userinfo['customerid']));
if (Settings::Get('ticket.concurrently_open') != - 1 && Settings::Get('ticket.concurrently_open') != '') {
$notmorethanxopentickets = strtr($lng['ticket']['notmorethanxopentickets'], array('%s' => Settings::Get('ticket.concurrently_open')));
} else {
$notmorethanxopentickets = '';
}
$ticketsopen = (int)$opentickets['count'];
eval("echo \"" . getTemplate("tickets/tickets") . "\";");
} elseif ($action == 'new') {
if ($userinfo['tickets_used'] < $userinfo['tickets'] || $userinfo['tickets'] == '-1') {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
$newticket = ticket::getInstanceOf($userinfo, -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') . "'");
$stmt = Database::prepare('UPDATE `' . TABLE_PANEL_CUSTOMERS . '`
SET `tickets_used`=`tickets_used` + 1
WHERE `customerid`= :customerid'
);
Database::pexecute($stmt, array("customerid" => $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_stmt = Database::prepare('SELECT `id`, `name` FROM `' . TABLE_PANEL_TICKET_CATS . '`
WHERE `adminid` = :adminid
ORDER BY `logicalorder`, `name` ASC'
);
$result = Database::pexecute_first($result_stmt, array("adminid" => $userinfo['adminid']));
if (isset($result['name']) && $result['name'] != '') {
$result2_stmt = Database::prepare('SELECT `id`, `name` FROM `' . TABLE_PANEL_TICKET_CATS . '`
WHERE `adminid` = :adminid
ORDER BY `logicalorder`, `name` ASC'
);
Database::pexecute($result2_stmt, array("adminid" => $userinfo['adminid']));
while ($row = $result2_stmt->fetch(PDO::FETCH_ASSOC)) {
$categories.= makeoption($row['name'], $row['id']);
}
} else {
$categories = makeoption($lng['ticket']['no_cat'], '0');
}
$priorities = makeoption($lng['ticket']['high'], '1');
$priorities.= makeoption($lng['ticket']['normal'], '2');
$priorities.= makeoption($lng['ticket']['low'], '3');
$ticketsopen = 0;
$opentickets_stmt = Database::prepare('SELECT COUNT(`id`) as `count` FROM `' . TABLE_PANEL_TICKETS . '`
WHERE `customerid` = :customerid
AND `answerto` = "0"
AND (`status` = "0" OR `status` = "1" OR `status` = "2")'
);
$opentickets = Database::pexecute_first($opentickets_stmt, array("customerid" => $userinfo['customerid']));
if (Settings::Get('ticket.concurrently_open') != -1 && Settings::Get('ticket.concurrently_open') != '') {
$notmorethanxopentickets = strtr($lng['ticket']['notmorethanxopentickets'], array('%s' => Settings::Get('ticket.concurrently_open')));
} else {
$notmorethanxopentickets = '';
}
$ticketsopen = (int)$opentickets['count'];
$ticket_add_data = include_once dirname(__FILE__).'/lib/formfields/customer/tickets/formfield.ticket_add.php';
$ticket_add_form = htmlform::genHTMLForm($ticket_add_data);
$title = $ticket_add_data['ticket_add']['title'];
$image = $ticket_add_data['ticket_add']['image'];
eval("echo \"" . getTemplate("tickets/tickets_new") . "\";");
}
} else {
standard_error('nomoreticketsavailable');
}
} elseif ($action == 'answer' && $id != 0) {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
try {
$replyticket = ticket::getInstanceOf($userinfo, -1);
} catch(Exception $e) {
standard_error($e->getMessage());
}
$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 {
try {
$mainticket = ticket::getInstanceOf($userinfo, (int)$id);
} catch(Exception $e) {
standard_error($e->getMessage());
}
$now = time();
$replyticket->Set('customer', (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
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 = '';
try {
$mainticket = ticket::getInstanceOf($userinfo, (int)$id);
} catch(Exception $e) {
standard_error($e->getMessage());
}
$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 {
$cid = $mainticket->Get('customer');
$usr_stmt = Database::prepare('SELECT `customerid`, `firstname`, `name`, `company`, `loginname`
FROM `' . TABLE_PANEL_CUSTOMERS . '`
WHERE `customerid` = :customerid '
);
$usr = Database::pexecute_first($usr_stmt, array("customerid" => $cid));
$by = getCorrectFullUserDetails($usr);
}
$subject = $mainticket->Get('subject');
$message = $mainticket->Get('message');
eval("\$ticket_replies.=\"" . getTemplate("tickets/tickets_tickets_main") . "\";");
$result_stmt = Database::prepare('SELECT `name` FROM `' . TABLE_PANEL_TICKET_CATS . '`
WHERE `id`= :id '
);
$row = Database::pexecute_first($result_stmt, array("id" => $mainticket->Get('category')));
$andere_stmt = Database::prepare('SELECT * FROM `' . TABLE_PANEL_TICKETS . '`
WHERE `answerto`= :answerto
ORDER BY `lastchange` ASC'
);
Database::pexecute($andere_stmt, array("answerto" => $id));
$numrows_andere = Database::num_rows();
while ($row2 = $andere_stmt->fetch(PDO::FETCH_ASSOC)) {
$subticket = ticket::getInstanceOf($userinfo, (int)$row2['id']);
$lastchange = date("d.m.Y H:i\h", $subticket->Get('lastchange'));
if ($subticket->Get('by') == '1') {
$by = $lng['ticket']['staff'];
} else {
$cid = $subticket->Get('customer');
$usr_stmt = Database::prepare('
SELECT `customerid`, `firstname`, `name`, `company`, `loginname`
FROM `' . TABLE_PANEL_CUSTOMERS . '`
WHERE `customerid` = :customerid '
);
$usr = Database::pexecute_first($usr_stmt, array("customerid" => $cid));
$by = getCorrectFullUserDetails($usr);
}
$subject = $subticket->Get('subject');
$message = $subticket->Get('message');
$row2 = htmlentities_array($row2);
eval("\$ticket_replies.=\"" . getTemplate("tickets/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 = htmlentities($mainticket->Get('subject'));
$ticket_replies_count = $numrows_andere + 1;
// don't forget the main-ticket!
$ticket_reply_data = include_once dirname(__FILE__).'/lib/formfields/customer/tickets/formfield.ticket_reply.php';
$ticket_reply_form = htmlform::genHTMLForm($ticket_reply_data);
$title = $ticket_reply_data['ticket_reply']['title'];
$image = $ticket_reply_data['ticket_reply']['image'];
eval("echo \"" . getTemplate("tickets/tickets_reply") . "\";");
}
} elseif ($action == 'close' && $id != 0) {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
$now = time();
try {
$mainticket = ticket::getInstanceOf($userinfo, (int)$id);
} catch(Exception $e) {
standard_error($e->getMessage());
}
$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 {
try {
$mainticket = ticket::getInstanceOf($userinfo, (int)$id);
} catch(Exception $e) {
standard_error($e->getMessage());
}
ask_yesno('ticket_reallyclose', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $mainticket->Get('subject'));
}
} elseif ($action == 'reopen' && $id != 0) {
$ticketsopen = 0;
$opentickets_stmt = Database::prepare('SELECT COUNT(`id`) as `count` FROM `' . TABLE_PANEL_TICKETS . '`
WHERE `customerid` = :customerid
AND `answerto` = "0"
AND (`status` = "0" OR `status` = "1" OR `status` = "2")'
);
$opentickets = Database::pexecute_first($opentickets_stmt, array("customerid" => $userinfo['customerid']));
$ticketsopen = (int)$opentickets['count'];
if ($ticketsopen > Settings::Get('ticket.concurrently_open') && Settings::Get('ticket.concurrently_open') != - 1 && Settings::Get('ticket.concurrently_open') != '') {
standard_error('notmorethanxopentickets', Settings::Get('ticket.concurrently_open'));
}
$now = time();
try {
$mainticket = ticket::getInstanceOf($userinfo, (int)$id);
} catch(Exception $e) {
standard_error($e->getMessage());
}
$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

@@ -16,16 +16,14 @@
* @package Panel * @package Panel
* *
*/ */
define('AREA', 'customer'); define('AREA', 'customer');
$intrafficpage = 1; $intrafficpage = 1;
require './lib/init.php'; require './lib/init.php';
use Froxlor\Database\Database;
use Froxlor\Settings;
// redirect if this customer page is hidden via settings // redirect if this customer page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options','traffic')) { if (Settings::IsInList('panel.customer_hide_options','traffic')) {
\Froxlor\UI\Response::redirectTo('customer_index.php'); redirectTo('customer_index.php');
} }
$traffic = ''; $traffic = '';
@@ -38,7 +36,8 @@ if (isset($_POST['month']) && isset($_POST['year'])) {
} elseif (isset($_GET['month']) && isset($_GET['year'])) { } elseif (isset($_GET['month']) && isset($_GET['year'])) {
$month = intval($_GET['month']); $month = intval($_GET['month']);
$year = intval($_GET['year']); $year = intval($_GET['year']);
} // BAM! $_GET??? }
//BAM! $_GET???
elseif (isset($_GET['page']) && $_GET['page'] == 'current') { elseif (isset($_GET['page']) && $_GET['page'] == 'current') {
if (date('d') != '01') { if (date('d') != '01') {
$month = date('m'); $month = date('m');
@@ -62,7 +61,8 @@ if (! is_null($month) && ! is_null($year)) {
AND `month` = :month AND `month` = :month
AND `year` = :year AND `year` = :year
GROUP BY `day` GROUP BY `day`
ORDER BY `day` DESC"); ORDER BY `day` DESC"
);
$params = array( $params = array(
"customerid" => $userinfo['customerid'], "customerid" => $userinfo['customerid'],
"month" => $month, "month" => $month,
@@ -86,39 +86,39 @@ if (! is_null($month) && ! is_null($year)) {
if (extension_loaded('bcmath')) { if (extension_loaded('bcmath')) {
$traf['ftptext'] = bcdiv($row['ftp_up'], 1024, Settings::Get('panel.decimal_places')) . " MiB up/ " . bcdiv($row['ftp_down'], 1024, Settings::Get('panel.decimal_places')) . " MiB down (FTP)"; $traf['ftptext'] = bcdiv($row['ftp_up'], 1024, Settings::Get('panel.decimal_places')) . " MiB up/ " . bcdiv($row['ftp_down'], 1024, Settings::Get('panel.decimal_places')) . " MiB down (FTP)";
$traf['httptext'] = bcdiv($http, 1024, Settings::Get('panel.decimal_places')) . " MiB (HTTP)";
$traf['mailtext'] = bcdiv($mail, 1024, Settings::Get('panel.decimal_places')) . " MiB (Mail)";
$traf['ftp'] = bcdiv($ftp, 1024, Settings::Get('panel.decimal_places')); $traf['ftp'] = bcdiv($ftp, 1024, Settings::Get('panel.decimal_places'));
$traf['http'] = bcdiv($http, 1024, Settings::Get('panel.decimal_places'));
$traf['mail'] = bcdiv($mail, 1024, Settings::Get('panel.decimal_places'));
$traf['byte'] = bcdiv($traf['byte'], 1024, Settings::Get('panel.decimal_places'));
} else { } else {
$traf['ftptext'] = round($row['ftp_up'] / 1024, Settings::Get('panel.decimal_places')) . " MiB up/ " . round($row['ftp_down'] / 1024, Settings::Get('panel.decimal_places')) . " MiB down (FTP)"; $traf['ftptext'] = round($row['ftp_up'] / 1024, Settings::Get('panel.decimal_places')) . " MiB up/ " . round($row['ftp_down'] / 1024, Settings::Get('panel.decimal_places')) . " MiB down (FTP)";
$traf['ftp'] = round($ftp / 1024, Settings::Get('panel.decimal_places')); $traf['httptext'] = round($http / 1024, Settings::Get('panel.decimal_places')) . " MiB (HTTP)";
$traf['mailtext'] = round($mail / 1024, Settings::Get('panel.decimal_places')) . " MiB (Mail)";
$traf['http'] = round($http, Settings::Get('panel.decimal_places'));
$traf['ftp'] = round($ftp, Settings::Get('panel.decimal_places'));
$traf['mail'] = round($mail, Settings::Get('panel.decimal_places'));
$traf['byte'] = round($traf['byte'] / 1024, Settings::Get('panel.decimal_places'));
} }
getReadableTraffic($traf,'httptext', $http, 1024, "MiB (HTTP)"); eval("\$traffic.=\"" . getTemplate('traffic/traffic_month') . "\";");
getReadableTraffic($traf,'http', $http, 1024);
getReadableTraffic($traf,'mailtext', $mail, 1024, "MiB (Mail)");
getReadableTraffic($traf,'mail', $mail, 1024);
getReadableTraffic($traf,'byte', $traf['byte'], (1024 * 1024));
eval("\$traffic.=\"" . \Froxlor\UI\Template::getTemplate('traffic/traffic_month') . "\";");
$show = $lng['traffic']['months'][intval($row['month'])] . ' ' . $row['year']; $show = $lng['traffic']['months'][intval($row['month'])] . ' ' . $row['year'];
} }
$traffic_complete['http'] = \Froxlor\PhpHelper::sizeReadable($traffic_complete['http'] * 1024, 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s'); $traffic_complete['http'] = size_readable($traffic_complete['http'] * 1024, 'GiB', 'bi', '%01.'.(int)Settings::Get('panel.decimal_places').'f %s');
$traffic_complete['ftp'] = \Froxlor\PhpHelper::sizeReadable($traffic_complete['ftp'] * 1024, 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s'); $traffic_complete['ftp'] = size_readable($traffic_complete['ftp'] * 1024, 'GiB', 'bi', '%01.'.(int)Settings::Get('panel.decimal_places').'f %s');
$traffic_complete['mail'] = \Froxlor\PhpHelper::sizeReadable($traffic_complete['mail'] * 1024, 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s'); $traffic_complete['mail'] = size_readable($traffic_complete['mail'] * 1024, 'GiB', 'bi', '%01.'.(int)Settings::Get('panel.decimal_places').'f %s');
eval("echo \"" . \Froxlor\UI\Template::getTemplate('traffic/traffic_details') . "\";"); eval("echo \"" . getTemplate('traffic/traffic_details') . "\";");
} else { } else {
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("SELECT `month`, `year`, SUM(`http`) AS http, SUM(`ftp_up`) AS ftp_up, SUM(`ftp_down`) AS ftp_down, SUM(`mail`) AS mail
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 . "` FROM `" . TABLE_PANEL_TRAFFIC . "`
WHERE `customerid` = :customerid WHERE `customerid` = :customerid
GROUP BY `year`, `month` GROUP BY `year` DESC, `month` DESC
ORDER BY `year` DESC, `month` DESC LIMIT 12"
LIMIT 12 );
"); Database::pexecute($result_stmt, array("customerid" => $userinfo['customerid']));
Database::pexecute($result_stmt, array(
"customerid" => $userinfo['customerid']
));
$traffic_complete['http'] = 0; $traffic_complete['http'] = 0;
$traffic_complete['ftp'] = 0; $traffic_complete['ftp'] = 0;
$traffic_complete['mail'] = 0; $traffic_complete['mail'] = 0;
@@ -138,33 +138,28 @@ if (! is_null($month) && ! is_null($year)) {
if (extension_loaded('bcmath')) { if (extension_loaded('bcmath')) {
$traf['ftptext'] = bcdiv($ftp_up, 1024, Settings::Get('panel.decimal_places')) . " MiB up/ " . bcdiv($ftp_down, 1024, Settings::Get('panel.decimal_places')) . " MiB down (FTP)"; $traf['ftptext'] = bcdiv($ftp_up, 1024, Settings::Get('panel.decimal_places')) . " MiB up/ " . bcdiv($ftp_down, 1024, Settings::Get('panel.decimal_places')) . " MiB down (FTP)";
$traf['httptext'] = bcdiv($http, 1024, Settings::Get('panel.decimal_places')) . " MiB (HTTP)";
$traf['mailtext'] = bcdiv($mail, 1024, Settings::Get('panel.decimal_places')) . " MiB (Mail)";
$traf['ftp'] = bcdiv(($ftp_up + $ftp_down), 1024, Settings::Get('panel.decimal_places')); $traf['ftp'] = bcdiv(($ftp_up + $ftp_down), 1024, Settings::Get('panel.decimal_places'));
$traf['http'] = bcdiv($http, 1024, Settings::Get('panel.decimal_places'));
$traf['mail'] = bcdiv($mail, 1024, Settings::Get('panel.decimal_places'));
$traf['byte'] = bcdiv($traf['byte'], 1024 * 1024, Settings::Get('panel.decimal_places'));
} else { } else {
$traf['ftptext'] = round($ftp_up / 1024, Settings::Get('panel.decimal_places')) . " MiB up/ " . round($ftp_down / 1024, Settings::Get('panel.decimal_places')) . " MiB down (FTP)"; $traf['ftptext'] = round($ftp_up / 1024, Settings::Get('panel.decimal_places')) . " MiB up/ " . round($ftp_down / 1024, Settings::Get('panel.decimal_places')) . " MiB down (FTP)";
$traf['httptext'] = round($http / 1024, Settings::Get('panel.decimal_places')) . " MiB (HTTP)";
$traf['mailtext'] = round($mail / 1024, Settings::Get('panel.decimal_places')) . " MiB (Mail)";
$traf['ftp'] = round(($ftp_up + $ftp_down) / 1024, Settings::Get('panel.decimal_places')); $traf['ftp'] = round(($ftp_up + $ftp_down) / 1024, Settings::Get('panel.decimal_places'));
$traf['http'] = round($http / 1024, Settings::Get('panel.decimal_places'));
$traf['mail'] = round($mail / 1024, Settings::Get('panel.decimal_places'));
$traf['byte'] = round($traf['byte'] / (1024 * 1024), Settings::Get('panel.decimal_places'));
} }
getReadableTraffic($traf,'httptext', $http, 1024, "MiB (HTTP)"); eval("\$traffic.=\"" . getTemplate('traffic/traffic_traffic') . "\";");
getReadableTraffic($traf,'http', $http, 1024);
getReadableTraffic($traf,'mailtext', $mail, 1024, "MiB (Mail)");
getReadableTraffic($traf,'mail', $mail, 1024);
getReadableTraffic($traf,'byte', $traf['byte'], (1024 * 1024));
eval("\$traffic.=\"" . \Froxlor\UI\Template::getTemplate('traffic/traffic_traffic') . "\";");
} }
$traffic_complete['http'] = \Froxlor\PhpHelper::sizeReadable($traffic_complete['http'] * 1024, 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s'); $traffic_complete['http'] = size_readable($traffic_complete['http'] * 1024, 'GiB', 'bi', '%01.'.(int)Settings::Get('panel.decimal_places').'f %s');
$traffic_complete['ftp'] = \Froxlor\PhpHelper::sizeReadable($traffic_complete['ftp'] * 1024, 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s'); $traffic_complete['ftp'] = size_readable($traffic_complete['ftp'] * 1024, 'GiB', 'bi', '%01.'.(int)Settings::Get('panel.decimal_places').'f %s');
$traffic_complete['mail'] = \Froxlor\PhpHelper::sizeReadable($traffic_complete['mail'] * 1024, 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s'); $traffic_complete['mail'] = size_readable($traffic_complete['mail'] * 1024, 'GiB', 'bi', '%01.'.(int)Settings::Get('panel.decimal_places').'f %s');
eval("echo \"" . \Froxlor\UI\Template::getTemplate('traffic/traffic') . "\";"); eval("echo \"" . getTemplate('traffic/traffic') . "\";");
}
function getReadableTraffic(&$traf, $index, $value, $divisor, $desc = "")
{
if (extension_loaded('bcmath')) {
$traf[$index] = bcdiv($value, $divisor,Settings::Get('panel.decimal_places')).(!empty($desc) ? " ".$desc : "");
} else {
$traf[$index] = round($value / $divisor, Settings::Get('panel.decimal_places')).(!empty($desc) ? " ".$desc : "");
}
} }

View File

@@ -1,8 +1,6 @@
<?php <?php
if (! defined('AREA')) { if (! defined('AREA'))
header("Location: index.php"); die('You cannot access this file directly!');
exit();
}
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
@@ -19,12 +17,10 @@ if (! defined('AREA')) {
* *
*/ */
use Froxlor\Api\Commands\DomainZones as DomainZones;
// This file is being included in admin_domains and customer_domains // This file is being included in admin_domains and customer_domains
// and therefore does not need to require lib/init.php // and therefore does not need to require lib/init.php
$domain_id = isset($_GET['domain_id']) ? (int) $_GET['domain_id'] : (isset($_POST['domain_id']) ? (int)$_POST['domain_id'] : null); $domain_id = isset($_GET['domain_id']) ? (int) $_GET['domain_id'] : null;
$record = isset($_POST['record']['record']) ? trim($_POST['record']['record']) : null; $record = isset($_POST['record']['record']) ? trim($_POST['record']['record']) : null;
$type = isset($_POST['record']['type']) ? $_POST['record']['type'] : 'A'; $type = isset($_POST['record']['type']) ? $_POST['record']['type'] : 'A';
@@ -33,63 +29,265 @@ $content = isset($_POST['record']['content']) ? trim($_POST['record']['content']
$ttl = isset($_POST['record']['ttl']) ? (int) $_POST['record']['ttl'] : 18000; $ttl = isset($_POST['record']['ttl']) ? (int) $_POST['record']['ttl'] : 18000;
// get domain-name // get domain-name
$domain = \Froxlor\Dns\Dns::getAllowedDomainEntry($domain_id, AREA, $userinfo); $domain = getAllowedDomainEntry($domain_id, AREA, $userinfo, $idna_convert);
$errors = ""; // select all entries
$sel_stmt = Database::prepare("SELECT * FROM `" . TABLE_DOMAIN_DNS . "` WHERE domain_id = :did");
Database::pexecute($sel_stmt, array(
'did' => $domain_id
));
$dom_entries = $sel_stmt->fetchAll(PDO::FETCH_ASSOC);
$errors = array();
$success_message = ""; $success_message = "";
// action for adding a new entry // action for adding a new entry
if ($action == 'add_record' && ! empty($_POST)) { if ($action == 'add_record' && ! empty($_POST)) {
try {
DomainZones::getLocal($userinfo, array( // validation
'id' => $domain_id, if (empty($record)) {
'record' => $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') {
// remove entry
if ($id > 0) {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
try {
DomainZones::getLocal($userinfo, array(
'entry_id' => $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());
} }
$record = strtolower($record);
if ($record != '@' && $record != '*') {
// validate record
if (strpos($record, '--') !== false) {
$errors[] = $lng['error']['domain_nopunycode'];
} else { } else {
\Froxlor\UI\HTML::askYesNo('dnsentry_reallydelete', $filename, array( // check for wildcard-record
'page' => $page, $add_wildcard_again = false;
'action' => $action, if (substr($record, 0, 2) == '*.') {
'id' => $id, $record = substr($record, 2);
'domain_id' => $domain_id $add_wildcard_again = true;
), $id); }
// convert entry
$record = $idna_convert->encode($record);
if ($add_wildcard_again) {
$record = '*.'.$record;
}
/*
* see https://redmine.froxlor.org/issues/1697
*
if ($type != 'SRV' && $type != 'TXT') {
$check_dom = $record . '.example.com';
if (! validateDomain($check_dom)) {
$errors[] = sprintf($lng['error']['subdomainiswrong'], $idna_convert->decode($record));
}
}
*/
if (strlen($record) > 63) {
$errors[] = $lng['error']['dns_record_toolong'];
} }
} }
} }
// select all entries // TODO regex validate content for invalid characters
try {
// get list if ($ttl <= 0) {
$json_result = DomainZones::getLocal($userinfo, [ $ttl = 18000;
'id' => $domain_id }
])->listing();
} catch (Exception $e) { if (empty($content)) {
\Froxlor\UI\Response::dynamic_error($e->getMessage()); $errors[] = $lng['error']['dns_content_empty'];
}
// types
if ($type == 'A' && filter_var($content, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === false) {
$errors[] = $lng['error']['dns_arec_noipv4'];
} elseif ($type == 'AAAA' && filter_var($content, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false) {
$errors[] = $lng['error']['dns_aaaarec_noipv6'];
} elseif ($type == 'MX') {
if ($prio === null || $prio < 0) {
$errors[] = $lng['error']['dns_mx_prioempty'];
}
// check for trailing dot
if (substr($content, - 1) == '.') {
// remove it for checks
$content = substr($content, 0, - 1);
}
if (! validateDomain($content)) {
$errors[] = $lng['error']['dns_mx_needdom'];
} else {
// check whether there is a CNAME-record for the same resource
foreach ($dom_entries as $existing_entries) {
$fqdn = $existing_entries['record'] . '.' . $domain;
if ($existing_entries['type'] == 'CNAME' && $fqdn == $content) {
$errors[] = $lng['error']['dns_mx_noalias'];
break;
}
}
}
// append trailing dot (again)
$content .= '.';
} elseif ($type == 'CNAME') {
// check for trailing dot
if (substr($content, - 1) == '.') {
// remove it for checks
$content = substr($content, 0, - 1);
} else {
// add domain name
$content .= '.' . $domain;
}
if (! validateDomain($content)) {
$errors[] = $lng['error']['dns_cname_invaliddom'];
} else {
// check whether there are RR-records for the same resource
foreach ($dom_entries as $existing_entries) {
if (($existing_entries['type'] == 'A' || $existing_entries['type'] == 'AAAA' || $existing_entries['type'] == 'MX' || $existing_entries['type'] == 'NS') && $existing_entries['record'] == $record) {
$errors[] = $lng['error']['dns_cname_nomorerr'];
break;
}
}
}
// append trailing dot (again)
$content .= '.';
} elseif ($type == 'NS') {
// check for trailing dot
if (substr($content, - 1) == '.') {
// remove it for checks
$content = substr($content, 0, - 1);
}
if (! validateDomain($content)) {
$errors[] = $lng['error']['dns_ns_invaliddom'];
}
// append trailing dot (again)
$content .= '.';
} elseif ($type == 'TXT' && ! empty($content)) {
// check that TXT content is enclosed in " "
$content = encloseTXTContent($content);
} elseif ($type == 'SRV') {
if ($prio === null || $prio < 0) {
$errors[] = $lng['error']['dns_srv_prioempty'];
}
// check only last part of content, as it can look like:
// _service._proto.name. TTL class SRV priority weight port target.
$_split_content = explode(" ", $content);
// SRV content must be [weight] [port] [target]
if (count($_split_content) != 3) {
$errors[] = $lng['error']['dns_srv_invalidcontent'];
}
$target = trim($_split_content[count($_split_content) - 1]);
if ($target != '.') {
// check for trailing dot
if (substr($target, - 1) == '.') {
// remove it for checks
$target = substr($target, 0, - 1);
}
}
if ($target != '.' && ! validateDomain($target)) {
$errors[] = $lng['error']['dns_srv_needdom'];
} else {
// check whether there is a CNAME-record for the same resource
foreach ($dom_entries as $existing_entries) {
$fqdn = $existing_entries['record'] . '.' . $domain;
if ($existing_entries['type'] == 'CNAME' && $fqdn == $target) {
$errors[] = $lng['error']['dns_srv_noalias'];
break;
}
}
}
// append trailing dot if there's none
if (substr($content, - 1) != '.') {
$content .= '.';
}
}
$new_entry = array(
'record' => $record,
'type' => $type,
'prio' => $prio,
'content' => $content,
'ttl' => $ttl,
'domain_id' => $domain_id
);
ksort($new_entry);
// check for duplicate
foreach ($dom_entries as $existing_entry) {
// compare json-encoded string of array
$check_entry = $existing_entry;
// new entry has no ID yet
unset($check_entry['id']);
// sort by key
ksort($check_entry);
// format integer fields to real integer (as they are read as string from the DB)
$check_entry['prio'] = (int) $check_entry['prio'];
$check_entry['ttl'] = (int) $check_entry['ttl'];
$check_entry['domain_id'] = (int) $check_entry['domain_id'];
// encode both
$check_entry = json_encode($check_entry);
$new = json_encode($new_entry);
// compare
if ($check_entry === $new) {
$errors[] = $lng['error']['dns_duplicate_entry'];
unset($check_entry);
break;
}
}
if (empty($errors)) {
$ins_stmt = Database::prepare("
INSERT INTO `" . TABLE_DOMAIN_DNS . "` SET
`record` = :record,
`type` = :type,
`prio` = :prio,
`content` = :content,
`ttl` = :ttl,
`domain_id` = :domain_id
");
Database::pexecute($ins_stmt, $new_entry);
$new_entry_id = Database::lastInsertId();
// add temporary to the entries-array (no reread of DB necessary)
$new_entry['id'] = $new_entry_id;
$dom_entries[] = $new_entry;
// success message (inline)
$success_message = $lng['success']['dns_record_added'];
$record = "";
$type = 'A';
$prio = "";
$content = "";
$ttl = "";
// re-generate bind configs
inserttask('4');
} else {
// show $errors
$errors = implode("<br>", $errors);
}
} elseif ($action == 'delete') {
// remove entry
$entry_id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
if ($entry_id > 0) {
$del_stmt = Database::prepare("DELETE FROM `" . TABLE_DOMAIN_DNS . "` WHERE `id` = :id");
Database::pexecute($del_stmt, array(
'id' => $entry_id
));
// remove deleted entry from internal data array (no reread of DB necessary)
$_t = $dom_entries;
foreach ($_t as $idx => $entry) {
if ($entry['id'] == $entry_id) {
unset($dom_entries[$idx]);
break;
}
}
unset($_t);
// success message (inline)
$success_message = $lng['success']['dns_record_deleted'];
// re-generate bind configs
inserttask('4');
}
} }
$result = json_decode($json_result, true)['data'];
$dom_entries = $result['list'];
// show editor // show editor
$record_list = ""; $record_list = "";
@@ -101,7 +299,7 @@ if (! empty($dom_entries)) {
$entriescount = count($dom_entries); $entriescount = count($dom_entries);
foreach ($dom_entries as $entry) { foreach ($dom_entries as $entry) {
$entry['content'] = wordwrap($entry['content'], 100, '<br>', true); $entry['content'] = wordwrap($entry['content'], 100, '<br>', true);
eval("\$existing_entries.=\"" . \Froxlor\UI\Template::getTemplate("dns_editor/entry_bit", true) . "\";"); eval("\$existing_entries.=\"" . getTemplate("dns_editor/entry_bit", true) . "\";");
} }
} }
@@ -109,32 +307,19 @@ if (! empty($dom_entries)) {
$type_select_values = array( $type_select_values = array(
'A', 'A',
'AAAA', 'AAAA',
'CAA',
'CNAME',
'DNAME',
'LOC',
'MX',
'NS', 'NS',
'RP', 'MX',
'SRV', 'SRV',
'SSHFP', 'TXT',
'TXT' 'CNAME'
); );
asort($type_select_values); asort($type_select_values);
foreach ($type_select_values as $_type) { foreach ($type_select_values as $_type) {
$type_select .= \Froxlor\UI\HTML::makeoption($_type, $_type, $type); $type_select .= makeoption($_type, $_type, $type);
} }
eval("\$record_list=\"" . \Froxlor\UI\Template::getTemplate("dns_editor/list", true) . "\";"); eval("\$record_list=\"" . getTemplate("dns_editor/list", true) . "\";");
try { $zone = createDomainZone($domain_id);
$json_result = DomainZones::getLocal($userinfo, array( $zonefile = (string) $zone;
'id' => $domain_id eval("echo \"" . getTemplate("dns_editor/index", true) . "\";");
))->get();
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$zonefile = implode("\n", $result);
eval("echo \"" . \Froxlor\UI\Template::getTemplate("dns_editor/index", true) . "\";");

View File

@@ -1,213 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2018 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2018-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package API-example
* @since 0.10.0
*
*/
class FroxlorAPI
{
/**
* URL to api.php of your froxlor installation
*
* @var string
*/
private $host = "";
/**
* your api-key
*
* @var string
*/
private $api_key = "";
/**
* your api-secret
*
* @var string
*/
private $api_secret = "";
/**
* last cURL error message
*
* @var string
*/
private $last_error = "";
/**
* last response header received
*
* @var array
*/
private $last_header = array();
/**
* last response data received
*
* @var array
*/
private $last_body = array();
/**
* create FroxlorAPI object
*
* @param string $host
* URL to api.php of your froxlor installation
* @param string $api_key
* your api-key
* @param string $api_secret
* your api-secret
*
* @return FroxlorAPI
*/
public function __construct(string $host, string $api_key, string $api_secret)
{
$this->host = $host;
$this->api_key = $api_key;
$this->api_secret = $api_secret;
}
/**
* send request to froxlor api
*
* @param string $command
* @param array $params
*
* @return FroxlorAPI
*/
public function request(string $command, array $params = array()): FroxlorAPI
{
// build request array
$request = [
'header' => [
'apikey' => $this->api_key,
'secret' => $this->api_secret
],
'body' => [
'command' => $command
]
];
// add parameter to request-body if any
if (! empty($params)) {
$request['body']['params'] = $params;
}
// reset last data
$this->last_header = array();
$this->last_body = array();
// send actual request
$response = $this->requestCurl(json_encode($request));
// decode response
$resp = json_decode($response[1], true);
// set body to data-part of response
$this->last_body = $resp['data'];
// set header of response
$this->last_header = [
'status' => $resp['status'],
'status_message' => $resp['status_message']
];
// check for error in api response
if (isset($this->last_header['status']) && $this->last_header['status'] >= 400) {
// set last-error message
$this->last_error .= "[" . $this->last_header['status'] . "] " . $this->last_header['status_message'];
}
return $this;
}
/**
* returns last response header
*
* @return array status|status_message
*/
public function getLastHeader(): array
{
return $this->last_header;
}
/**
* returns last response data
*
* @return array
*/
public function getLastResponse(): array
{
if (!empty($this->getLastError())) {
// nothing is returned when the last call
// was not successful
return [];
}
return $this->last_body;
}
/**
* return last known error message
*
* @return string
*/
public function getLastError(): string
{
return $this->last_error;
}
/**
* send cURL request to api
*
* @param string $data
* json array
*
* @return array header|body
*/
private function requestCurl(string $data): array
{
// reset last error message
$this->last_error = "";
$ch = curl_init($this->host);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-type: application/json'
));
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_HEADER, 1);
$verbose = fopen('php://temp', 'w+');
curl_setopt($ch, CURLOPT_STDERR, $verbose);
if (! $data = curl_exec($ch)) {
$this->last_error = 'Curl execution error: ' . curl_error($ch) . "\n";
rewind($verbose);
$verboseLog = stream_get_contents($verbose);
$this->last_error .= "Verbose information: " . htmlspecialchars($verboseLog) . "\n";
}
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($data, 0, $header_size);
$body = substr($data, $header_size);
curl_close($ch);
return array(
$header,
$body
);
}
}

View File

@@ -1,48 +0,0 @@
<?php
// include FroxlorAPI helper class
require __DIR__ . '/FroxlorAPI.php';
// create object of FroxlorAPI with URL, apikey and apisecret
$fapi = new FroxlorAPI('https://froxlor.your-host.tld/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
$fapi->request('Customers.add', $data);
// check for error
if (! empty($fapi->getLastError())) {
echo "Error: " . $fapi->getLastError();
exit();
}
// get response of request
$request = $fapi->getLastResponse();
// view response data
var_dump($request);
/*
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,22 +0,0 @@
<?php
// include FroxlorAPI helper class
require __DIR__ . '/FroxlorAPI.php';
// create object of FroxlorAPI with URL, apikey and apisecret
$fapi = new FroxlorAPI('https://froxlor.your-host.tld/api.php', 'your-api-key', 'your-api-secret');
// send request
$fapi->request('Froxlor.listFunctions');
// check for error
if (! empty($fapi->getLastError())) {
echo "Error: " . $fapi->getLastError();
exit();
}
// get response of request
$request = $fapi->getLastResponse();
// view response data
var_dump($request);

View File

978
index.php

File diff suppressed because it is too large Load Diff

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