Compare commits

...

271 Commits

Author SHA1 Message Date
Michael Kaufmann
c6f556c8d9 set version to 0.10.29.1 for bugfix release
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-10-10 14:45:17 +02:00
Michael Kaufmann
db1df84ef1 correct db-exists check in installation-process
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-10-10 14:32:02 +02:00
Michael Kaufmann
52135a1d3a set version to 0.10.29 for upcoming release
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-10-08 08:46:58 +02:00
Michael Kaufmann
7f13bd09da add optional ssl parameters to powerdns-config-template
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-10-08 08:39:22 +02:00
Nick Ufer
7ccbb37c4e feat: adds mysql tls support (#979) 2021-10-08 08:28:32 +02:00
Michael Kaufmann
7feddf0aec generate unpredictable unique session ids
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-10-02 12:38:17 +02:00
Michael Kaufmann
e73523531a let user decide whether an existing database should be backup'ed and removed when installing froxlor; dont rely on parse_ini_file for OS check; enhance mysqldump so there is no issues with complex passwords and bash-escaping
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-09-24 10:49:57 +02:00
Michael Kaufmann
a47b790e19 actually integrate the new czech language file; refs #976
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-09-04 09:30:44 +02:00
Michael Kaufmann
319eec6124 fix session for 2fa enabled logins
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-08-27 13:17:05 +02:00
Michael Kaufmann
21983f27b6 secure commonly used filename-variable against url manipulation
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-08-25 16:36:09 +02:00
Michael Kaufmann
5d375b784d login action always goes to index.php
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-08-25 16:30:56 +02:00
Michael Kaufmann
4b22470872 set php session security related settings (correctly in every case)
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-08-25 16:21:33 +02:00
Michael Kaufmann
ec1c37aa06 set version to 0.10.28 for upcoming release
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-08-20 09:23:23 +02:00
Nicolas
67351ec3c2 Adding support for PowerDNS-Replication (#974)
Adding support for powerdns-replication
2021-08-19 12:00:09 +02:00
Michael Kaufmann
f1887aaaf2 enable iterate_query in dovecot by default
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-08-13 09:28:10 +02:00
Michael Kaufmann
afd2d7b5e9 fix dns-validation in Domains.add() and Domains.update() when using Let's Encrypt DNS-check
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-08-08 11:14:57 +02:00
Michael Kaufmann
c967e585b5 avoid duplicate entries in mysql-access-host setting
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-08-06 08:11:06 +02:00
Michael Kaufmann
73e364d4ba fix compare of old/new value of aliasdomain when editing a domain as customer to avoid unnecessary regeneration of configfiles
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-08-04 14:55:22 +02:00
Michael Kaufmann
eb49331b21 remove superfluous inserttask when editing domain as it will be called when there are actually changes to the domain earlier
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-08-04 14:06:32 +02:00
Michael Kaufmann
0a1a3e023f check dns for lets encrypt when adding/editing domains and via cron; fixes #971
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-08-04 13:44:13 +02:00
Michael Kaufmann
bef5cedcd0 only add link to customername when editing domain when panel.allow_domain_change_customer is false
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-08-02 16:58:34 +02:00
Stefan Weil
f8e2bc7bff Fix some typos in code (found by codespell) (#970)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2021-08-01 19:00:33 +02:00
Stefan Weil
09038ac7aa Fix some typos (found by codespell) (#969)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2021-07-31 09:51:54 +02:00
Michael Kaufmann
4c507232c7 add setting for a custom system group for all customer-users (required libnss-extrausers); fixes #953
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-07-30 12:16:37 +02:00
Michael Kaufmann
86939a64da add buypass testing/staging ACME endpoint; create CAA entries accordingly if activated; refs #968
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-07-29 21:24:43 +02:00
Jens Meißner
926ce427fc Add Buypass to the list of ACME providers. (#968) 2021-07-29 21:15:49 +02:00
Michael Kaufmann
53401eebfb integrity check should allow utf8_* charachter sets and not only 'utf8', thx to lod
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-07-29 21:04:46 +02:00
Michael Kaufmann
bef580929e Update README.md 2021-07-27 08:14:08 +02:00
Michael Kaufmann
c7b7c67ff4 normalize ipv6 addresses to avoid possible comparison problems; fixes #965
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-07-26 17:53:44 +02:00
Michael Kaufmann
ed42d4e3df try to fix github action...
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-07-24 20:31:34 +02:00
Michael Kaufmann
69a2ebce36 create user as froxlor would create it for mysql-8.0
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-07-24 20:29:56 +02:00
Michael Kaufmann
15f08739fa add github action workflow for mysql
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-07-24 20:17:42 +02:00
nachtgeist
571690c8c5 admin_customers/edit domain: make customer login name a link (#962) 2021-07-23 16:35:31 +02:00
rex2630
b2005d7f29 [WIP] Czech language (#870)
* Update czech.lng.php
2021-07-21 20:41:07 +02:00
Michael Kaufmann
4354598c64 fix unittests
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-07-21 10:21:58 +02:00
Michael Kaufmann
05d4bdc499 restore behaviour for unittests as 'create stdsubdomain' default was yes in the settings but no for direct API usage
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-07-21 10:10:18 +02:00
Michael Kaufmann
25c6a37df2 fix wrong variable-name in Customers.delete()
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-07-21 10:03:20 +02:00
Michael Kaufmann
41a470fe36 added option to disable creation of default subdomain; fixes #960
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-07-21 09:53:54 +02:00
Michael Kaufmann
8a4aa2a721 fix lng strings
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-07-20 23:45:57 +02:00
Michael Kaufmann
1d903770fc have more power over theme logo, custom theme logo and uploaded logo; refs #958
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-07-20 20:35:54 +02:00
Nicolas
934be5a238 Fix SOA-Record (#959) 2021-07-20 19:29:06 +02:00
Michael Kaufmann
5608f0407f correct heredoc indentation in AcmeSh for php-7.1; fixes #957
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-07-20 08:11:32 +02:00
Kai
ce9d8dad7f Feature-request #672 - database name prefixes + custom name (#956)
* Fix makeoption function call

* Update formfield.mysql_add.php

Added database name

* Update formfield.mysql_add.php

* Update formfield.mysql_add.php

* Update Mysqls.php

* Update DbManager.php

* Update formfield.mysql_add.php

* Update german.lng.php

* Update formfield.mysql_add.php

* Update Mysqls.php

* Added field database_name (Feature #672)

* Added Testfunction for customer choosed database name

* Fixed test for customer choosed database name
Added docs for param $name

* Fixed mysql api command add
Removed doubled code

* Set settings for customer choosed db name

* Fixed wrong excepted for database name

* Renamed parameter database_name to custom_suffix

* Changed testCustomerMysqlsList
Added testCustomerMysqlsDBNameDelete
2021-07-19 19:10:12 +02:00
Michael Kaufmann
d6fe263e68 Update issue templates 2021-07-19 07:20:46 +02:00
Michael Kaufmann
156846a845 set version to 0.10.27 for upcoming release
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-07-18 10:57:38 +02:00
Michael Kaufmann
abe00b79a7 Update README.md
add github actions build badge
2021-07-17 14:16:29 +02:00
Michael Kaufmann
26ab659c6a Ga testing (#955)
* switch from travis-ci to github actions

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-07-17 14:14:35 +02:00
Michael Kaufmann
b0273c68d2 remove debian jessie config-templates (outdated); set debian stretch as deprecated; add debian bullseye config templates
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-07-16 12:15:03 +02:00
Michael Kaufmann
720cf9d74f Merge branch 'master' of github.com:Froxlor/Froxlor 2021-07-13 09:01:25 +02:00
Michael Kaufmann
35cd567c48 check whether there was an image upload at all
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-07-13 09:01:22 +02:00
Michael Kaufmann
2332d5be7b Merge pull request #949 from bashgeek/custom-css
Custom CSS File in default theme
2021-07-13 08:38:23 +02:00
Daniel
14cdc3801a Merge branch 'Froxlor-master' into custom-css 2021-07-13 10:31:35 +08:00
Daniel
d85efe480e conflict 2021-07-13 10:31:24 +08:00
Daniel
4f2ceaa3ab wip 2021-07-13 10:29:36 +08:00
Michael Kaufmann
3b6792d548 Merge branch 'master' of github.com:Froxlor/Froxlor 2021-07-12 17:29:25 +02:00
Michael Kaufmann
36de6e09d4 remove beta notice from let's encrypt settings
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-07-12 17:29:21 +02:00
Michael Kaufmann
300c410b18 Merge pull request #948 from bashgeek/logo-custom-login
Custom Logo(s) via Image-Upload in Panel Settings
2021-07-12 17:28:42 +02:00
Daniel Schmitz
282d7d9101 migrate old image + fix versioning 2021-07-09 17:07:50 +08:00
Daniel Schmitz
48f6601003 check mime types 2021-07-09 16:42:21 +08:00
Daniel
c4c4279171 Merge branch 'Froxlor:master' into logo-custom-login 2021-07-09 16:32:59 +08:00
Michael Kaufmann
b88f9c1f18 allow defining php_value/php_admin_value for session.save_path when using php-fpm; fixes #954
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-07-09 08:23:46 +02:00
Daniel Schmitz
0dac045dc9 wip 2021-07-07 14:11:54 +08:00
Daniel Schmitz
80b5f97367 wip 2021-07-07 14:10:21 +08:00
Daniel Schmitz
7a8b39fad0 wip 2021-07-07 14:00:55 +08:00
Daniel Schmitz
9f5978e875 german translations 2021-07-07 13:33:33 +08:00
Daniel
155fd757bf Merge branch 'Froxlor:master' into logo-custom-login 2021-07-07 13:30:22 +08:00
Daniel Schmitz
518ec202ab wip 2021-07-07 13:26:15 +08:00
Michael Kaufmann
871083d613 Merge pull request #952 from bashgeek/install-warnings
Installer Cleanup & Bug Fixes
2021-06-28 08:06:59 +02:00
Daniel Schmitz
79f0c8d28f wip 2021-06-28 11:01:22 +08:00
Daniel
dfbb4127e2 Merge branch 'Froxlor:master' into logo-custom-login 2021-06-28 10:39:02 +08:00
Daniel Schmitz
b9b2f00f30 wip 2021-06-28 10:37:23 +08:00
Daniel Schmitz
6923f9d926 Revert "wip"
This reverts commit cacbf7fec7.
2021-06-28 10:35:15 +08:00
Daniel Schmitz
cacbf7fec7 wip 2021-06-28 10:34:21 +08:00
Michael Kaufmann
73991e855c Support ZeroSSL via acme.sh (v3); refs #946
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-06-27 09:00:44 +02:00
Michael Kaufmann
0208812013 prefer custom zone entries over automatically created ones when system.dns_createmailentry is enabled, fixes #944
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-06-27 08:41:16 +02:00
Michael Kaufmann
48bd2561f7 Merge pull request #947 from Froxlor/dependabot/composer/phpmailer/phpmailer-6.5.0
Bump phpmailer/phpmailer from 6.4.1 to 6.5.0
2021-06-27 08:37:38 +02:00
Michael Kaufmann
af12c4102b Merge pull request #950 from kruegerj/patch-1
Update focal.xml
2021-06-24 07:57:00 +02:00
kruegerj
d2efa3ecc4 Update focal.xml 2021-06-24 03:16:12 +02:00
Daniel Schmitz
acb04566f5 wip 2021-06-23 11:28:07 +08:00
Daniel Schmitz
abb98ae960 wip 2021-06-23 11:21:33 +08:00
Daniel Schmitz
0d202a7e4d wip 2021-06-23 11:20:18 +08:00
Daniel Schmitz
c69ef20b17 wip 2021-06-23 10:58:52 +08:00
dependabot[bot]
5872d0682a Bump phpmailer/phpmailer from 6.4.1 to 6.5.0
Bumps [phpmailer/phpmailer](https://github.com/PHPMailer/PHPMailer) from 6.4.1 to 6.5.0.
- [Release notes](https://github.com/PHPMailer/PHPMailer/releases)
- [Changelog](https://github.com/PHPMailer/PHPMailer/blob/master/changelog.md)
- [Commits](https://github.com/PHPMailer/PHPMailer/compare/v6.4.1...v6.5.0)

---
updated-dependencies:
- dependency-name: phpmailer/phpmailer
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-22 15:20:44 +00:00
Michael Kaufmann
c4fa8feb8c update dev tools
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-06-17 08:25:43 +02:00
Michael Kaufmann
61a50cc657 add setting for default serveralias value for new domains, refs #944
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-06-16 15:10:52 +02:00
Michael Kaufmann
3df3261ac0 switch from freenode irc network to libera.chat irc network as freenode is dead
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-06-16 11:57:38 +02:00
Michael Kaufmann
f2636e14f0 Merge pull request #945 from MisterDuval/patch-1
Deny all robots
2021-06-01 15:06:31 +02:00
MisterDuval
a23f22f561 Deny all robots
Search engine and all Robots should be denied to the whole Froxlor directory. This file will help!
2021-06-01 14:45:47 +02:00
Michael Kaufmann
8cf3f4ee24 set version to 0.10.26 for upcoming maintenance releasae
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-05-14 08:21:53 +02:00
Michael Kaufmann
e83f7634f8 Merge pull request #938 from Froxlor/dependabot/composer/phpmailer/phpmailer-6.4.1
Bump phpmailer/phpmailer from 6.2.0 to 6.4.1
2021-05-04 19:57:10 +02:00
dependabot[bot]
6eb6595a46 Bump phpmailer/phpmailer from 6.2.0 to 6.4.1
Bumps [phpmailer/phpmailer](https://github.com/PHPMailer/PHPMailer) from 6.2.0 to 6.4.1.
- [Release notes](https://github.com/PHPMailer/PHPMailer/releases)
- [Changelog](https://github.com/PHPMailer/PHPMailer/blob/master/changelog.md)
- [Commits](https://github.com/PHPMailer/PHPMailer/compare/v6.2.0...v6.4.1)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-04 17:43:20 +00:00
Michael Kaufmann
bd48fb7328 catch exception of password-complexity check when changing account password; fixes #935
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-04-14 08:59:44 +02:00
Michael Kaufmann
769525bb56 do not touch/chown error/access log if log is disabled, fixes #934
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-04-12 09:42:25 +02:00
Michael Kaufmann
9195fb3c98 additionally sort by length of username for libnss-extrausers passwd file to have the main user as first in result in any case; fixes #933
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-04-12 09:37:36 +02:00
Michael Kaufmann
82922f7aea add new settings for legal-notes; terms-of-use and privacy-policy; fixes #930
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-03-24 14:36:48 +01:00
Michael Kaufmann
db1a39b6d9 match composePhpOptions() definition everywhere
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-03-24 13:49:58 +01:00
Michael Kaufmann
7fbbc2ea0b add vhost replacer {FPMSOCKET} for custom vhost configs; fixes #931
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-03-24 13:46:24 +01:00
Michael Kaufmann
91d4432108 check rr against possible existing CNAME entries, fixes #927
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-03-15 17:33:30 +01:00
Michael Kaufmann
c8914312aa Refactoring columns from large table to avoid '1118 Row size too large' error
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-03-11 09:45:52 +01:00
Michael Kaufmann
3fd89c48e8 set version to 0.10.25 for upcoming maintenance release
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-03-05 20:27:55 +01:00
Michael Kaufmann
eceb144a77 also trigger removal of domain in powerdns database if used; refs #923
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-03-04 12:09:03 +01:00
Michael Kaufmann
1d9651b18a trgger acme.sh removal for domains if customers is being deleted; fixes #923
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-03-04 12:07:20 +01:00
Michael Kaufmann
49db4e60cb escape passwords for email content (new email-account, new ftp-account and new database); fixes #905
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-03-03 11:25:58 +01:00
Michael Kaufmann
53e8ccbccb added 'deactivated' parameter to EmailAccounts.update() so admins can disable individual email-accounts, will be overridden if customer is deactivatd and re-enabled; fixes #921
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-03-03 10:59:16 +01:00
Michael Kaufmann
6d8fc215f1 add description field to panel_domains and mail_virtual table, API parameter 'description' for Domains.add()/Domains.update() and Email.add()/Emails.update(); fixes #910
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-03-03 10:25:42 +01:00
Michael Kaufmann
f94c303cb3 add API parameter 'show_usages' for Customers.listing() and Customers.get() to return number of domains, and diskspaced used split into webspace_used, mailspace_used and dbspace_used; fixes #912
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-03-03 09:50:30 +01:00
Michael Kaufmann
2be1873354 fix frontend issue with displaying correct options in domain listing when using php8, thx to cscholz
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-02-24 19:56:26 +01:00
Michael Kaufmann
d1d36c32fe Merge pull request #920 from RipClaw2971/patch-1
lowercase domain names for ssl-certificate file check (fallback)
2021-02-24 13:07:26 +01:00
RipClaw2971
3b3527348f Update AcmeSh.php
Renewed certificates are not recognized if the domain is in upper/lower case.
2021-02-24 13:00:31 +01:00
Michael Kaufmann
036d5f0713 Merge pull request #919 from nachtgeist/soa
dns: make mail address of SOA records configurable
2021-02-21 18:27:57 +01:00
Daniel Reichelt
a1b8807b0f dns: make mail address of SOA records configurable 2021-02-21 13:00:30 +01:00
Michael Kaufmann
356a087b6a Merge pull request #918 from nachtgeist/pns
dns: check NS entry to be used as primary NS
2021-02-21 09:14:37 +01:00
Michael Kaufmann
0a77fd7150 Merge pull request #917 from nachtgeist/pw
system: validatePassword(): also quote the delimiter ('/')
2021-02-21 09:13:02 +01:00
Daniel Reichelt
67d67a287f system: validatePassword(): also quote the delimiter ('/')
Quoting the default regex delimiter is required for the password
complexity check to work if '/' had been specified as special character
in Froxlor's account settings.
2021-02-21 02:33:46 +01:00
Daniel Reichelt
1f792466bf dns: check NS entry to be used as primary NS
Don't just blindly use the first custom NS entry for SOA, actually check
if it pertains to the domain in question
2021-02-21 02:33:23 +01:00
Michael Kaufmann
5a6343b47c php8 compatibility, fixes #916
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-02-16 12:38:01 +01:00
Michael Kaufmann
841c529107 fix check for required firstname/name/company in Customers.update(), fixes #915
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-02-15 23:26:18 +01:00
Michael Kaufmann
41c3f21f0b list only phpenabled and http-enabled domains in php-configuration overview; fixes #911
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-02-11 16:16:04 +01:00
Michael Kaufmann
b8c0688ba0 added possibility to use 'in' sql-operation in sql_where parameter for Api-calls; php-8 compat fix in admin_traffic
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-02-11 12:09:42 +01:00
Michael Kaufmann
24e02e99fb set version to 0.10.24 for upcoming maintenance release
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-02-05 15:46:08 +01:00
Michael Kaufmann
97bb7b6227 add filecontent to allowed form-fields to not be escaped
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-02-05 15:44:49 +01:00
Michael Kaufmann
5ceddc8c65 remove not (yet) used cli script
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-02-05 15:42:38 +01:00
Michael Kaufmann
3a17d03796 add option to specify (optional) fileextension/suffix for generated dkim-private keys; fixes #907
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-01-20 12:12:41 +01:00
Michael Kaufmann
57ae195930 for percentage calculation always use bytes so we don't compare KiB with GiB or similar
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-01-18 21:22:29 +01:00
Michael Kaufmann
9b86d576fa do not display usages on dashboard in fixed size-units but dynamically adjusted
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-01-18 20:49:55 +01:00
Michael Kaufmann
02a12eda13 add missing field 'include_default_vhostconf' to settings table for new installations
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-01-16 10:50:49 +01:00
Michael Kaufmann
a31da97d66 exclude some formfields from xss-cleaning as it could alter the wanted content
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-01-13 10:14:51 +01:00
Michael Kaufmann
9f13aa9a12 only pass binding variable for prepared sql statement if variable exists
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-01-13 08:52:00 +01:00
Michael Kaufmann
2841051649 correctly read in domain's ssl-ips for CAA entries if enabled, fixes #903
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-01-12 21:08:10 +01:00
Michael Kaufmann
acfbf55d15 Check return of validateFormField() just for non-falsey values and not expect boolean data-type; fixes #904
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-01-12 19:17:38 +01:00
Michael Kaufmann
5848df28fd Merge pull request #902 from bashgeek/master
Put in trailing slash to /awstats/ location in nginx config
2021-01-12 12:25:22 +01:00
Michael Kaufmann
21925f48c3 set minimum required php-version to 7.1 and recommended php-version to 7.4
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2021-01-06 13:36:35 +01:00
Daniel
17a64c58c2 Put in a trailing "/" for /awstats/ location 2020-12-31 16:01:42 +08:00
Daniel
0ca38cff31 Merge pull request #1 from Froxlor/master
up
2020-12-31 15:59:07 +08:00
Michael Kaufmann
5efc1849b4 fix hide-incompatible-settings feature
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-12-30 17:16:15 +01:00
Michael Kaufmann
f213d666e2 fix typo
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-12-30 16:46:01 +01:00
Michael Kaufmann
78495b6487 update link to perl-fastcgi wiki on nginx.com; added setting to hide incompatible settings (depending on webserver)
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-12-30 16:41:26 +01:00
Michael Kaufmann
ab1c76e104 set version to 0.10.23.1 for bugfix release
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-12-28 19:48:31 +01:00
Michael Kaufmann
a671223823 corrected too few arguments to function Froxlor\Cron\Traffic\TrafficCron::callAwstatsGetTraffic(); fixes #901
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-12-28 19:43:40 +01:00
Michael Kaufmann
3a99e10296 set version to 0.10.23 for upcoming maintenance release
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-12-28 11:09:56 +01:00
Michael Kaufmann
38031aaff9 add missing return-code in DomainZones.add which messes up the error handling when using API
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-12-23 13:42:36 +01:00
Michael Kaufmann
65773bce57 automatically set php-fpm default config to php-version that is used for the installation to avoid confusion
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-12-21 17:15:02 +01:00
Michael Kaufmann
ee5de56a94 also validate existence of ssl-key file in vhost generation
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-12-10 09:47:58 +01:00
Michael Kaufmann
aba97df9b2 added date-range parameters for Traffic.listing(), fixes #878
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-12-10 09:44:43 +01:00
Michael Kaufmann
79e670f797 trigger rebuild of cronjobs also if customer email is changed, fixes #896
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-12-10 09:41:35 +01:00
Michael Kaufmann
8670cb6742 Merge pull request #900 from heptalium/master
Protect only private keys and leave certificates world readable.
2020-12-10 09:29:51 +01:00
Michael Kaufmann
bde87950a5 fix optional parameters of phpErrHandler
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-11-27 14:07:01 +01:00
Jens Meißner
aa1d2ab01d Set certificate files explicitly world readable. 2020-11-24 17:38:49 +01:00
Jens Meißner
2a770a93b1 Protect only private keys and leave certificates world readable. 2020-11-23 20:32:24 +01:00
Michael Kaufmann
5b85a1c183 use Validate::validateEmail() also for PHPMailer::ValidateAddress() call
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-11-17 17:31:49 +01:00
Michael Kaufmann
caf8893558 use Validate::validateEmail() instead of pure filter_var
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-11-17 17:18:23 +01:00
Michael Kaufmann
a280461cf6 add unicode flag for filter-validate-email (>=php7.1)
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-11-17 10:39:11 +01:00
Michael Kaufmann
455c655580 corrected validation of idn-tld's, fixes #899
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-11-14 11:59:46 +01:00
Michael Kaufmann
ecd707424f change example of dhparams.pem folder so it does not conflict with default ssl-certificates-folder which gets purged by froxlor regulary
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-11-13 13:01:19 +01:00
Michael Kaufmann
60fe330de1 Merge pull request #875 from negrusti/patch-2
Data integrity - remove default values from some columns
2020-11-12 09:01:03 +01:00
Michael Kaufmann
cdb871b82b fix delete_userfiles flag not being passed via webinterface email-address-overview
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-11-12 08:54:52 +01:00
Michael Kaufmann
35c4e3d1b9 set version to 0.10.22 for upcoming maintenance release
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-11-06 14:47:20 +01:00
Michael Kaufmann
b3f82f0981 remove duplicate AXFR records as nameserver get added automatically in case they have also been added to the axfr list
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-11-01 21:00:27 +01:00
Michael Kaufmann
b1b68364be do not allow setting www as CNAME record if domain has automatic www-Alias enabled, fixes #895
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-10-31 16:16:05 +01:00
Michael Kaufmann
ea76ce8fcc secure requests; refs #893
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-10-31 15:57:59 +01:00
Michael Kaufmann
16eca628dd add Unittest for traffic-filtering by customer-name, refs #894
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-10-31 15:53:07 +01:00
Michael Kaufmann
6bf5eccc24 update dependencies and add voku\AntiXSS
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-10-31 15:50:16 +01:00
Michael Kaufmann
63d00cd453 forgot to add the language strings to the commit for avoid deletion of (super)admin
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-10-31 15:48:01 +01:00
Michael Kaufmann
c79cba26f3 avoid deletion of (super)admin with id 1 due to fallbacks in the code using it; fixes #886
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-10-31 10:02:11 +01:00
Michael Kaufmann
36eb3cc1aa [domainbulk] remove reqiurement for customer-select in webinterface as it is an API-parameter
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-10-31 09:45:50 +01:00
Michael Kaufmann
15a13a7783 append file-extension for dkim-private-keys as external tools may require it (rspamd e.g.); thx to rseffner for finding this
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-10-20 15:28:51 +02:00
Michael Kaufmann
816874872d make given documentroot of domain relative to customerroot of no absolute path if given; fixes #892
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-10-14 16:58:19 +02:00
Michael Kaufmann
0e8449f28d Merge pull request #891 from andlinger/patch-1
Fixed typo in contribution document
2020-10-14 14:26:48 +02:00
Michael Kaufmann
3dcbbb9e7b do not set description to empty value if not passed as parameter as it is optionally; fixes #890
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-10-14 14:25:23 +02:00
David Andlinger
5ab9e6865d fixed typo 2020-10-14 14:17:37 +02:00
Michael Kaufmann
3a47b2050e fix awstats/webalizer directory protection when using nginx; fixes #888
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-10-13 20:18:44 +02:00
Michael Kaufmann
907c475361 create quotatallies entry if it not exists, fixes #885; correction in api-doc for Ftps.update ftp_password parameter, fixes #889
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-10-13 19:52:29 +02:00
Michael Kaufmann
0dfb4bdcdb list dns entries after add/delete action handling so the table of entries always shows the current state withouth reloading the page; fixes #887
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-10-12 09:50:48 +02:00
Michael Kaufmann
a5dc7b93a2 unify customerid/loginname api-parameter-descriptions; fixes #883
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-10-05 19:59:02 +02:00
Michael Kaufmann
244d2823a6 Merge pull request #882 from heavygale/patch-3
Fix for notices "Trying to access array offset on value of type bool" in ReportsCron.php
2020-10-03 13:10:40 +02:00
heavygale
2f0251bb19 Fix for "Trying to access array offset on value of type bool"
Proper check for success of query before accessing the result array. This notices occures if there's no custom mail-template for trafficmaxpercent_subject or trafficmaxpercent_mailbody for the required language.
2020-10-03 12:55:14 +02:00
Michael Kaufmann
a37d795ff3 set version to 0.10.21 for maintenance release
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-10-02 18:01:53 +02:00
Michael Kaufmann
d9331cca61 check for fallback of ssl-certificate in ips/ports correctly of lets encrypt is used
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-09-18 11:49:26 +02:00
Michael Kaufmann
f169129e27 remove obsolete/unused table
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-09-07 21:53:18 +02:00
Michael Kaufmann
746548492b output traffic values correctly when not using bcmath and kind of fix wrong unit display on mouseover, fixes #425
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-09-07 21:51:24 +02:00
Michael Kaufmann
4ad8b62576 for ssl-fallback-check not only check for empty value but also for existence of certificate, thx to df8oe
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-09-06 14:12:25 +02:00
Michael Kaufmann
1eed3d1166 remove underscore from dkim-selector when creating the certificates too, refs #619
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-08-13 09:04:58 +02:00
Michael Kaufmann
6a32720c9a remove underscore from dkim-selector in the output certificate files too as (old) dkim-filter read the selector from this filename; refs #619
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-08-09 10:54:22 +02:00
Michael Kaufmann
e389ae4bf8 setting version to 0.10.20 for upcoming maintenance release
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-08-07 19:43:16 +02:00
Michael Kaufmann
970ecb469e use overridden limit_extensions and idle_timeout in vhost config when using fpm and not mod_proxy
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-08-07 17:16:56 +02:00
Grigory Morozov
92b6914610 Update froxlor.sql
Data integrity - under no circumstances the empty string is a valid value for these fields
2020-08-07 21:58:06 +07:00
Michael Kaufmann
7e57352bc0 remove underscore from dkim-selector, refs #619
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-07-30 07:59:22 +02:00
Michael Kaufmann
e3d42a3f62 show current count of results besides total count in listings, fixes #869
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-07-29 08:46:50 +02:00
Michael Kaufmann
456a287621 fix missing query-parameters for IpsAndPorts.listing() when using sql_search
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-07-29 08:36:55 +02:00
Michael Kaufmann
eff630da8d unset any limit as we do not have pagination when showing search-results, refs #869
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-07-29 08:28:04 +02:00
Michael Kaufmann
aa45a0302e fix permanent rebuilding of vhost configs, refs 0af655f106
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-07-29 08:23:49 +02:00
Michael Kaufmann
aa14487995 update jquery library, fixes #872
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-07-28 13:28:47 +02:00
Michael Kaufmann
10b52486b5 ups, forgot to save the file so it's missing a critical return :P
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-07-25 17:28:46 +02:00
Michael Kaufmann
0af655f106 fix permanent rebuilding of vhost configs due to always-true renew check of let's encrypt certificates
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-07-25 17:21:52 +02:00
Michael Kaufmann
665c87cca7 fix index on longtext field which is not working due to unknown length; fixes #868
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-07-25 17:21:13 +02:00
Michael Kaufmann
1c50838d37 Merge pull request #871 from tczaude/master
issue 868 : Add new performance indexes
2020-07-24 20:37:26 +02:00
tczaude
ac5bc78e12 fix showUpdateStep 2020-07-24 19:32:04 +02:00
tczaude
a5e6ef674f issue 868 : Add new performerce indexes 2020-07-24 14:35:55 +02:00
Michael Kaufmann
03bc94e69c insert task to sync certificates for all cases (issue and renew)
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-07-07 12:10:40 +02:00
Michael Kaufmann
37176c94a1 set version to 0.10.19 for upcoming release
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-07-03 14:12:48 +02:00
Michael Kaufmann
a141c83ad4 do not call strtotime on the validTo_time_t key of cert_data as it already is an UNIX-timestamp, refs #865
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-06-23 20:35:50 +02:00
Michael Kaufmann
7c3ff95d22 check for possible CNAME overrides of A/AAAA record in dns-editor, fixes #864
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-06-23 09:39:00 +02:00
Michael Kaufmann
d653f6842f check for acme.sh upgrade on every run; fix not running --install-cronjob without having an issue command
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-06-21 19:50:46 +02:00
Michael Kaufmann
35a69fbfe0 add missing parmeter customerid for SubDomains.delete() which is required when called as admin; fixes #862
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-06-18 13:05:17 +02:00
Michael Kaufmann
e733701459 trigger removal cronjob of lets encrypt certificate via acme.sh also when domain update removes letsencrypt flag from domain
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-06-17 14:09:26 +02:00
Michael Kaufmann
70677fced2 fix double-adding of _ecc to certificate folder when deleting let's encrypt certificate
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-06-17 12:08:54 +02:00
Michael Kaufmann
daa223ed42 return full domain object on Domains.update() call, fixes #861
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-06-17 09:29:02 +02:00
Michael Kaufmann
0398f4cdba set version to 0.10.18 for upcoming release
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-06-12 15:17:09 +02:00
Michael Kaufmann
1a0953e77e fix typo in response status message, fixes #858
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-06-08 11:42:44 +02:00
Michael Kaufmann
490704f8e1 Heredoc/nowdoc with an indented closing marker is not supported in PHP 7.2 or earlier.
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-06-06 20:57:24 +02:00
Michael Kaufmann
2748f1b633 also display error when domain does not resolv to any A or AAAA record in lets-encrypt-dns-validation
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-06-06 15:37:06 +02:00
Michael Kaufmann
8e60c6b201 update api documentation for Ftps.update(), fixes #857
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-06-05 16:23:41 +02:00
Michael Kaufmann
d4716b2376 correct documentation for Customers.add(), fixes #856
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-06-05 15:33:49 +02:00
Michael Kaufmann
2c98fc4c2d fix wrong certificate folder for fallback ceck (ecc/non-ecc)
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-06-04 07:42:13 +02:00
Michael Kaufmann
65e1f633ef Merge pull request #855 from daxara/detect_distr
Auto detection in CLI & checks
2020-05-31 20:59:26 +02:00
Ante de Baas
ed4dbba278 also perform checks in Install class 2020-05-31 20:46:27 +02:00
Ante de Baas
1a6082ca91 complete if statement 2020-05-31 20:36:52 +02:00
Ante de Baas
da1d94149a saet defaults and do some checks 2020-05-31 20:34:47 +02:00
Ante de Baas
e7cfceb65d add comment 2020-05-31 20:18:37 +02:00
Ante de Baas
1f48ca4711 autodeterct distribution in CLI 2020-05-31 20:10:07 +02:00
Michael Kaufmann
fe0fb8dd5f fix non-static method called statically in \Froxlor\FileDir
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-05-31 16:38:53 +02:00
Michael Kaufmann
4a5ab7d95d Merge pull request #854 from daxara/detect_distr
fix bugs in dist detection
2020-05-31 16:36:52 +02:00
Ante de Baas
0d44adf265 fix bugs is dist detection 2020-05-31 16:00:50 +02:00
Michael Kaufmann
0b63b4e110 Merge pull request #853 from daxara/centos7
[centos7] proftp requires epel, awstats needs install and awstats cron moved
2020-05-31 15:02:57 +02:00
Michael Kaufmann
ba7e9688c5 Merge pull request #852 from daxara/centos8
Centos8 config updated
2020-05-31 15:02:31 +02:00
Ante de Baas
443ae1df68 proftp requires epel, awstats needs install and awstats cron moved 2020-05-31 14:57:07 +02:00
Ante de Baas
b59aa6f140 undo dnf -y 2020-05-31 14:28:37 +02:00
Ante de Baas
4e9df61fef awstats cron is moved to cron.hourly 2020-05-31 13:15:55 +02:00
Ante de Baas
b350815aa0 install awstats and requirements 2020-05-31 13:11:58 +02:00
Ante de Baas
b672c722b9 no user interaction on package installation 2020-05-31 13:05:52 +02:00
Ante de Baas
db60606cfa proftpd requires epel 2020-05-31 12:52:31 +02:00
Ante de Baas
2524491883 centos8 uses 'dandified yum' 2020-05-31 12:47:28 +02:00
Ante de Baas
de061e7e36 add missing apacheconf_htpasswddir dir 2020-05-31 12:46:33 +02:00
Michael Kaufmann
9ecd182a91 Merge pull request #851 from daxara/master
rename rhel7 to centos7 for consistency
2020-05-31 11:26:12 +02:00
Ante de Baas
a7934bcb7b rename rhel7 to centos7 for consistancy 2020-05-31 11:17:43 +02:00
Michael Kaufmann
9dc2c09da7 Merge pull request #850 from daxara/rhel8
Add CentOS 8 configuration-templates
2020-05-31 09:30:51 +02:00
Michael Kaufmann
b23e4a4d85 Merge pull request #849 from daxara/detect_distr
Detect distribution upon installation and set setting-defaults (if any) for that distribution
2020-05-31 09:29:42 +02:00
Michael Kaufmann
394ec4cd4a fix ecc certificate paths
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-05-31 09:13:22 +02:00
Ante de Baas
6ccfb7efbb remove old code 2020-05-30 10:10:57 +02:00
Ante de Baas
1454d8d40f get defaults from configparser 2020-05-30 10:08:05 +02:00
Ante de Baas
0fde1ce7e9 remove dev comment 2020-05-30 09:15:15 +02:00
Ante de Baas
86155f7a9c use Distribution in german language 2020-05-30 09:11:43 +02:00
Ante de Baas
60578a5d31 rename to CentOS because its most likely to be used 2020-05-29 17:46:38 +02:00
Ante de Baas
7fcacb4637 rename to centos because its most likey to be used 2020-05-29 17:45:37 +02:00
Ante de Baas
fb35fb9a3a read distribution from xml and selection via selectbox 2020-05-29 17:33:48 +02:00
Ante de Baas
6128954231 rename propery to property 2020-05-29 15:54:37 +02:00
Ante de Baas
f4d4490d08 change property tagnames 2020-05-29 15:45:04 +02:00
Ante de Baas
27f0c4eb53 remove distribution names from language files 2020-05-29 15:42:38 +02:00
Ante de Baas
cb1df3a7e0 show failue as nice red message 2020-05-29 15:29:53 +02:00
Ante de Baas
a572ac3914 add rhel8 config file 2020-05-29 15:10:06 +02:00
Ante de Baas
498ff15e98 add redhat defaults 2020-05-29 14:59:48 +02:00
Ante de Baas
022ed1a9a8 add setting defaults per distribution when given 2020-05-29 14:59:40 +02:00
Ante de Baas
814339cc73 Merge branch 'master' into detect_distr 2020-05-29 13:54:36 +02:00
Ante de Baas
0bb48a3cdf fix nginx capitalisation. 2020-05-29 13:45:46 +02:00
Ante de Baas
67d74406bd add os distribution detection 2020-05-29 13:36:31 +02:00
Michael Kaufmann
d73d8da2fd read certificate data folder from acme.sh.env file, fixes #846
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-05-28 20:08:49 +02:00
Michael Kaufmann
3c7bdcb5e0 Merge pull request #847 from Froxlor/dependabot/composer/phpmailer/phpmailer-6.1.6
Bump phpmailer/phpmailer from 6.1.4 to 6.1.6
2020-05-28 10:47:26 +02:00
dependabot[bot]
c6ac73f74f Bump phpmailer/phpmailer from 6.1.4 to 6.1.6
Bumps [phpmailer/phpmailer](https://github.com/PHPMailer/PHPMailer) from 6.1.4 to 6.1.6.
- [Release notes](https://github.com/PHPMailer/PHPMailer/releases)
- [Changelog](https://github.com/PHPMailer/PHPMailer/blob/master/changelog.md)
- [Commits](https://github.com/PHPMailer/PHPMailer/compare/v6.1.4...v6.1.6)

Signed-off-by: dependabot[bot] <support@github.com>
2020-05-27 17:01:04 +00:00
Michael Kaufmann
fdcb294244 Merge pull request #844 from daxara/dns_rhel7
Named DNS for RHEL7
2020-05-25 22:02:40 +02:00
Ante de Baas
8898c7c165 add named dns config 2020-05-25 21:38:58 +02:00
Michael Kaufmann
d4c0acb353 Merge pull request #843 from rubo77/usage
show disk-usage also on unlimited accounts
2020-05-25 09:28:37 +02:00
Ruben Barkow-Kuder
9ea32b69cb show disk-usage also on unlimited accounts
Signed-off-by: Ruben Barkow-Kuder <github@r.z11.de>
2020-05-25 03:14:38 +02:00
Michael Kaufmann
0524c70d2b add config-templates for ubuntu focal (partly tested only for now)
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-05-24 12:16:17 +02:00
Michael Kaufmann
6ca7920147 fix missing language files in config-services cli script; set ubuntu xenial deprecated, remove Ubuntu trusty; fix a2dismod command in buster config-template as php7.3 is default
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-05-24 11:55:20 +02:00
Michael Kaufmann
65b2e4efa7 do not check for mariadb.sys user on mariadb-10.4 when testing with travis
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-05-23 21:17:43 +02:00
Michael Kaufmann
7000fd2c30 Merge pull request #841 from rubo77/patch-1
Don't suggest php5 during update as default
2020-05-23 21:16:39 +02:00
Ruben Barkow-Kuder
3b1ff03b33 Don't suggest php5 during update as default 2020-05-23 20:12:27 +02:00
Michael Kaufmann
ffa9205f95 fix sql query to remove duplicates before setting unique key in updater, fixes #840
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-05-18 20:48:56 +02:00
Michael Kaufmann
bc73ed0c75 adjust tls default value to tlsv1.2; refs #839
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2020-05-18 20:48:04 +02:00
Michael Kaufmann
17fd350d33 Merge pull request #839 from negrusti/patch-2
TLSv1 is deprecated
2020-05-18 20:07:30 +02:00
Grigory Morozov
c2e57dfd60 TLSv1 is deprecated 2020-05-18 05:18:42 +07:00
187 changed files with 14593 additions and 4351 deletions

View File

@@ -1,4 +0,0 @@
codecov:
notify:
require_ci_to_pass: no

View File

@@ -48,7 +48,7 @@ strings in
### New settings and database-layout changnes ### New settings and database-layout changes
If you add new settings or layout changes, please make sure you add these to If you add new settings or layout changes, please make sure you add these to
* `install/froxlor.sql` * `install/froxlor.sql`

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 freenode * contact us via IRC in #froxlor on irc.libera.chat
* or post a thread in our forum at https://forum.froxlor.org * or post a thread in our forum at https://forum.froxlor.org
As a rule of thumb: before reporting an issue As a rule of thumb: before reporting an issue

40
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,40 @@
---
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

@@ -0,0 +1,20 @@
---
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.

80
.github/workflows/build-mariadb.yml vendored Normal file
View File

@@ -0,0 +1,80 @@
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 }}

57
.github/workflows/build-mysql.yml vendored Normal file
View File

@@ -0,0 +1,57 @@
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

3
.gitignore vendored
View File

@@ -12,9 +12,10 @@ logs/*
.well-known .well-known
.idea .idea
*.iml *.iml
img/
!templates/Froxlor/ !templates/Froxlor/
!templates/Sparkle/ !templates/Sparkle/
!templates/misc/ !templates/misc/
templates/Froxlor/assets/img/logo_custom.png templates/Sparkle/assets/css/custom.css
vendor/ vendor/

View File

@@ -52,13 +52,10 @@ install:
- mysql -h 127.0.0.1 --protocol=TCP -u root -pfr0xl0r.TravisCI froxlor010 < install/froxlor.sql - mysql -h 127.0.0.1 --protocol=TCP -u root -pfr0xl0r.TravisCI froxlor010 < install/froxlor.sql
script: script:
- ant phpunit - ant phpunit-no-coverage
after_success:
- bash <(curl -s https://codecov.io/bash) -f "build/logs/clover.xml"
notifications: notifications:
irc: "chat.freenode.net#froxlor" irc: "irc.libera.chat#froxlor"
webhooks: webhooks:
urls: urls:
- https://webhooks.gitter.im/e/bdf91d1c3f745e51f796 - https://webhooks.gitter.im/e/bdf91d1c3f745e51f796

View File

@@ -1,4 +1,5 @@
[![Build Status](https://travis-ci.com/Froxlor/Froxlor.svg?branch=master)](https://travis-ci.com/Froxlor/Froxlor) [![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)
[![Gitter](https://badges.gitter.im/Froxlor/community.svg)](https://gitter.im/Froxlor/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![Gitter](https://badges.gitter.im/Froxlor/community.svg)](https://gitter.im/Froxlor/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
# Froxlor # Froxlor
@@ -28,8 +29,8 @@ You may find help in the following places:
### IRC ### IRC
froxlor may be found on freenode.net, channel #froxlor: froxlor may be found on libera.chat, channel #froxlor:
irc://chat.freenode.net/froxlor irc://irc.libera.chat/froxlor
### Forum ### Forum

View File

@@ -77,14 +77,6 @@ return array(
'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'],
'settinggroup' => 'panel', 'settinggroup' => 'panel',
@@ -265,7 +257,71 @@ return array(
'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

@@ -205,9 +205,21 @@ return array(
'default' => false, 'default' => false,
'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

@@ -270,6 +270,28 @@ return array(
'default' => true, 'default' => true,
'save_method' => 'storeSettingField' '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

@@ -35,7 +35,7 @@ return array(
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'ssl_protocols', 'varname' => 'ssl_protocols',
'type' => 'option', 'type' => 'option',
'default' => 'TLSv1,TLSv1.2', 'default' => 'TLSv1.2',
'option_mode' => 'multiple', 'option_mode' => 'multiple',
'option_options' => array( 'option_options' => array(
'TLSv1' => 'TLSv1', 'TLSv1' => 'TLSv1',
@@ -142,6 +142,9 @@ 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',
@@ -154,16 +157,20 @@ return array(
), ),
'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' => 'production', 'default' => 'letsencrypt',
'option_mode' => 'one', 'option_mode' => 'one',
'option_options' => array( 'option_options' => array(
'testing' => 'https://acme-staging-v0' . \Froxlor\Settings::Get('system.leapiversion') . '.api.letsencrypt.org (Test)', 'letsencrypt_test' => 'Let\'s Encrypt (Test / Staging)',
'production' => 'https://acme-v0' . \Froxlor\Settings::Get('system.leapiversion') . '.api.letsencrypt.org (Live)' 'letsencrypt' => 'Let\'s Encrypt (Live)',
'buypass_test' => 'Buypass (Test / Staging)',
'buypass' => 'Buypass (Live)',
'zerossl' => 'ZeroSSL (Live)'
), ),
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
), ),

View File

@@ -99,6 +99,19 @@ return array(
'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'],
'settinggroup' => 'system', 'settinggroup' => 'system',
@@ -132,6 +145,16 @@ return array(
'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

@@ -39,6 +39,15 @@ return array(
'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'],
'settinggroup' => 'dkim', 'settinggroup' => 'dkim',

View File

@@ -82,7 +82,20 @@ return array(
'string_emptyallowed' => true, 'string_emptyallowed' => true,
'default' => '', 'default' => '',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
) ),
'system_froxlorusergroup' => array(
'label' => $lng['serversettings']['froxlorusergroup'],
'settinggroup' => 'system',
'varname' => 'froxlorusergroup',
'type' => 'string',
'default' => '',
'save_method' => 'storeSettingField',
'plausibility_check_method' => array(
'\\Froxlor\\Validate\\Check',
'checkLocalGroup'
),
'visible' => \Froxlor\Settings::Get('system.nssextrausers')
),
) )
) )
) )

View File

@@ -107,7 +107,7 @@ if ($page == 'admins' && $userinfo['change_serversettings'] == '1') {
$count ++; $count ++;
} }
$admincount = $paging->getEntries(); $admincount = $result['count'] . " / " . $paging->getEntries();
eval("echo \"" . \Froxlor\UI\Template::getTemplate("admins/admins") . "\";"); eval("echo \"" . \Froxlor\UI\Template::getTemplate("admins/admins") . "\";");
} elseif ($action == 'su') { } elseif ($action == 'su') {
@@ -129,7 +129,7 @@ if ($page == 'admins' && $userinfo['change_serversettings'] == '1') {
'userid' => $userinfo['userid'] 'userid' => $userinfo['userid']
)); ));
$s = md5(uniqid(microtime(), 1)); $s = \Froxlor\Froxlor::genSessionId();
$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,

View File

@@ -87,7 +87,7 @@ if ($page == 'showinfo') {
$hits = $cache['num_hits'] . @sprintf(" (%.1f%%)", $cache['num_hits'] * 100 / ($cache['num_hits'] + $cache['num_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 / ($cache['num_hits'] + $cache['num_misses'])); $misses = $cache['num_misses'] . @sprintf(" (%.1f%%)", $cache['num_misses'] * 100 / ($cache['num_hits'] + $cache['num_misses']));
// Fragementation: (freeseg - 1) / total_seg // Fragmentation: (freeseg - 1) / total_seg
$nseg = $freeseg = $fragsize = $freetotal = 0; $nseg = $freeseg = $fragsize = $freetotal = 0;
for ($i = 0; $i < $mem['num_seg']; $i ++) { for ($i = 0; $i < $mem['num_seg']; $i ++) {
$ptr = 0; $ptr = 0;

View File

@@ -150,7 +150,7 @@ if ($page == 'customers' && $userinfo['customers'] != '0') {
$count ++; $count ++;
} }
$customercount = $paging->getEntries(); $customercount = $result['count'] . " / " . $paging->getEntries();
eval("echo \"" . \Froxlor\UI\Template::getTemplate("customers/customers") . "\";"); eval("echo \"" . \Froxlor\UI\Template::getTemplate("customers/customers") . "\";");
} elseif ($action == 'su' && $id != 0) { } elseif ($action == 'su' && $id != 0) {
try { try {
@@ -178,7 +178,7 @@ if ($page == 'customers' && $userinfo['customers'] != '0') {
'hash' => $s 'hash' => $s
)); ));
$s = md5(uniqid(microtime(), 1)); $s = \Froxlor\Froxlor::genSessionId();
$insert = Database::prepare(" $insert = Database::prepare("
INSERT INTO `" . TABLE_PANEL_SESSIONS . "` SET INSERT INTO `" . TABLE_PANEL_SESSIONS . "` SET
`hash` = :hash, `hash` = :hash,

View File

@@ -80,7 +80,7 @@ if ($page == 'domains' || $page == 'overview') {
$count++; $count++;
} }
$domainscount = $paging->getEntries(); $domainscount = $result['count'] . " / " . $paging->getEntries();
// Display the list // Display the list
eval("echo \"" . \Froxlor\UI\Template::getTemplate("domains/domains") . "\";"); eval("echo \"" . \Froxlor\UI\Template::getTemplate("domains/domains") . "\";");
@@ -290,9 +290,9 @@ if ($page == 'domains' || $page == 'overview') {
// create serveralias options // create serveralias options
$serveraliasoptions = ""; $serveraliasoptions = "";
$serveraliasoptions .= \Froxlor\UI\HTML::makeoption($lng['domains']['serveraliasoption_wildcard'], '0', '0', true, true); $serveraliasoptions .= \Froxlor\UI\HTML::makeoption($lng['domains']['serveraliasoption_wildcard'], '0', Settings::Get('system.domaindefaultalias'), true, true);
$serveraliasoptions .= \Froxlor\UI\HTML::makeoption($lng['domains']['serveraliasoption_www'], '1', '0', true, true); $serveraliasoptions .= \Froxlor\UI\HTML::makeoption($lng['domains']['serveraliasoption_www'], '1', Settings::Get('system.domaindefaultalias'), true, true);
$serveraliasoptions .= \Froxlor\UI\HTML::makeoption($lng['domains']['serveraliasoption_none'], '2', '0', true, true); $serveraliasoptions .= \Froxlor\UI\HTML::makeoption($lng['domains']['serveraliasoption_none'], '2', Settings::Get('system.domaindefaultalias'), true, true);
$subcanemaildomain = \Froxlor\UI\HTML::makeoption($lng['admin']['subcanemaildomain']['never'], '0', '0', true, true); $subcanemaildomain = \Froxlor\UI\HTML::makeoption($lng['admin']['subcanemaildomain']['never'], '0', '0', true, true);
$subcanemaildomain .= \Froxlor\UI\HTML::makeoption($lng['admin']['subcanemaildomain']['choosableno'], '1', '0', true, true); $subcanemaildomain .= \Froxlor\UI\HTML::makeoption($lng['admin']['subcanemaildomain']['choosableno'], '1', '0', true, true);
@@ -428,7 +428,7 @@ if ($page == 'domains' || $page == 'overview') {
$customer = Database::pexecute_first($customer_stmt, array( $customer = Database::pexecute_first($customer_stmt, array(
'customerid' => $result['customerid'] 'customerid' => $result['customerid']
)); ));
$result['customername'] = \Froxlor\User::getCorrectFullUserDetails($customer) . ' (' . $customer['loginname'] . ')'; $result['customername'] = \Froxlor\User::getCorrectFullUserDetails($customer);
} }
if ($userinfo['customers_see_all'] == '1') { if ($userinfo['customers_see_all'] == '1') {
@@ -594,6 +594,10 @@ if ($page == 'domains' || $page == 'overview') {
} }
$result = \Froxlor\PhpHelper::htmlentitiesArray($result); $result = \Froxlor\PhpHelper::htmlentitiesArray($result);
if (Settings::Get('panel.allow_domain_change_customer') != '1') {
$result['customername'] .= ' (<a href="' . $linker->getLink(array('section' => 'customers', 'page' => 'customers',
'action' => 'su', 'id' => $customer['customerid'])) . '" rel="external">' . $customer['loginname'] . '</a>)';
}
$domain_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/domains/formfield.domains_edit.php'; $domain_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/domains/formfield.domains_edit.php';
$domain_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($domain_edit_data); $domain_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($domain_edit_data);
@@ -616,7 +620,6 @@ if ($page == 'domains' || $page == 'overview') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
$customerid = intval($_POST['customerid']);
$separator = \Froxlor\Validate\Validate::validate($_POST['separator'], 'separator'); $separator = \Froxlor\Validate\Validate::validate($_POST['separator'], 'separator');
$offset = (int) \Froxlor\Validate\Validate::validate($_POST['offset'], 'offset', "/[0-9]/i"); $offset = (int) \Froxlor\Validate\Validate::validate($_POST['offset'], 'offset', "/[0-9]/i");
@@ -625,7 +628,7 @@ if ($page == 'domains' || $page == 'overview') {
$result = array(); $result = array();
try { try {
$bulk = new \Froxlor\Bulk\DomainBulkAction($file_name, $customerid); $bulk = new \Froxlor\Bulk\DomainBulkAction($file_name, $userinfo);
$result = $bulk->doImport($separator, $offset); $result = $bulk->doImport($separator, $offset);
} catch (Exception $e) { } catch (Exception $e) {
\Froxlor\UI\Response::standard_error('domain_import_error', $e->getMessage()); \Froxlor\UI\Response::standard_error('domain_import_error', $e->getMessage());
@@ -647,19 +650,6 @@ if ($page == 'domains' || $page == 'overview') {
'page' => 'domains' 'page' => 'domains'
)); ));
} else { } else {
$customers = \Froxlor\UI\HTML::makeoption($lng['panel']['please_choose'], 0, 0, true);
$result_customers_stmt = Database::prepare("
SELECT `customerid`, `loginname`, `name`, `firstname`, `company`
FROM `" . TABLE_PANEL_CUSTOMERS . "` " . ($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = '" . (int) $userinfo['adminid'] . "' ") . " ORDER BY `name` ASC");
$params = array();
if ($userinfo['customers_see_all'] == '0') {
$params['adminid'] = $userinfo['adminid'];
}
Database::pexecute($result_customers_stmt, $params);
while ($row_customer = $result_customers_stmt->fetch(PDO::FETCH_ASSOC)) {
$customers .= \Froxlor\UI\HTML::makeoption(\Froxlor\User::getCorrectFullUserDetails($row_customer) . ' (' . $row_customer['loginname'] . ')', $row_customer['customerid']);
}
$domain_import_data = include_once dirname(__FILE__) . '/lib/formfields/admin/domains/formfield.domains_import.php'; $domain_import_data = include_once dirname(__FILE__) . '/lib/formfields/admin/domains/formfield.domains_import.php';
$domain_import_form = \Froxlor\UI\HtmlForm::genHTMLForm($domain_import_data); $domain_import_form = \Froxlor\UI\HtmlForm::genHTMLForm($domain_import_data);

View File

@@ -57,6 +57,12 @@ if (isset($_POST['id'])) {
if ($page == 'overview') { if ($page == 'overview') {
$log->logAction(\Froxlor\FroxlorLogger::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`,
@@ -68,20 +74,18 @@ if ($page == 'overview') {
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, array( $overview = Database::pexecute_first($overview_stmt, $params);
'adminid' => $userinfo['adminid']
));
$dec_places = Settings::Get('panel.decimal_places'); $dec_places = Settings::Get('panel.decimal_places');
$overview['traffic_used'] = round($overview['traffic_used'] / (1024 * 1024), $dec_places); $overview['traffic_bytes_used'] = $overview['traffic_used'] * 1024;
$overview['diskspace_used'] = round($overview['diskspace_used'] / 1024, $dec_places); $overview['traffic_used'] = \Froxlor\PhpHelper::sizeReadable($overview['traffic_used'] * 1024, null, 'bi');
$overview['diskspace_bytes_used'] = $overview['diskspace_used'] * 1024;
$overview['diskspace_used'] = \Froxlor\PhpHelper::sizeReadable($overview['diskspace_used'] * 1024, null, 'bi');
$number_domains_stmt = Database::prepare(" $number_domains_stmt = Database::prepare("
SELECT COUNT(*) AS `number_domains` FROM `" . TABLE_PANEL_DOMAINS . "` SELECT COUNT(*) AS `number_domains` FROM `" . TABLE_PANEL_DOMAINS . "`
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, array( $number_domains = Database::pexecute_first($number_domains_stmt, $params);
'adminid' => $userinfo['adminid']
));
$overview['number_domains'] = $number_domains['number_domains']; $overview['number_domains'] = $number_domains['number_domains'];
@@ -111,11 +115,17 @@ if ($page == 'overview') {
} }
$dec_places = Settings::Get('panel.decimal_places'); $dec_places = Settings::Get('panel.decimal_places');
$userinfo['diskspace'] = round($userinfo['diskspace'] / 1024, $dec_places); // get everything in bytes for the percentage calculation on the dashboard
$userinfo['diskspace_used'] = round($userinfo['diskspace_used'] / 1024, $dec_places); $userinfo['diskspace_bytes'] = ($userinfo['diskspace'] > -1) ? $userinfo['diskspace'] * 1024 : -1;
$userinfo['traffic'] = round($userinfo['traffic'] / (1024 * 1024), $dec_places); $userinfo['diskspace_bytes_used'] = $userinfo['diskspace_used'] * 1024;
$userinfo['traffic_used'] = round($userinfo['traffic_used'] / (1024 * 1024), $dec_places); $userinfo['traffic_bytes'] = ($userinfo['traffic'] > -1) ? $userinfo['traffic'] * 1024 : - 1;
$userinfo = \Froxlor\PhpHelper::strReplaceArray('-1', $lng['customer']['unlimited'], $userinfo, 'customers domains diskspace traffic mysqls emails email_accounts email_forwarders email_quota ftps subdomains'); $userinfo['traffic_bytes_used'] = $userinfo['traffic_used'] * 1024;
$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']) : '';
@@ -183,8 +193,12 @@ if ($page == 'overview') {
\Froxlor\UI\Response::standard_error('oldpasswordnotcorrect'); \Froxlor\UI\Response::standard_error('oldpasswordnotcorrect');
} }
$new_password = \Froxlor\Validate\Validate::validate($_POST['new_password'], 'new password'); try {
$new_password_confirm = \Froxlor\Validate\Validate::validate($_POST['new_password_confirm'], 'new password confirm'); $new_password = \Froxlor\System\Crypt::validatePassword($_POST['new_password'], 'new password');
$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( \Froxlor\UI\Response::standard_error(array(

View File

@@ -32,10 +32,10 @@ if ($page == 'message') {
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'viewed panel_message'); $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'viewed panel_message');
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
if ($_POST['receipient'] == 0 && $userinfo['customers_see_all'] == '1') { if ($_POST['recipient'] == 0 && $userinfo['customers_see_all'] == '1') {
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'sending messages to admins'); $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'sending messages to admins');
$result = Database::query('SELECT `name`, `email` FROM `' . TABLE_PANEL_ADMINS . "`"); $result = Database::query('SELECT `name`, `email` FROM `' . TABLE_PANEL_ADMINS . "`");
} elseif ($_POST['receipient'] == 1) { } elseif ($_POST['recipient'] == 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(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'sending messages to ALL customers');
$result = Database::query('SELECT `firstname`, `name`, `company`, `email` FROM `' . TABLE_PANEL_CUSTOMERS . "`"); $result = Database::query('SELECT `firstname`, `name`, `company`, `email` FROM `' . TABLE_PANEL_CUSTOMERS . "`");
@@ -49,7 +49,7 @@ if ($page == 'message') {
)); ));
} }
} else { } else {
\Froxlor\UI\Response::standard_error('noreceipientsgiven'); \Froxlor\UI\Response::standard_error('norecipientsgiven');
} }
$subject = $_POST['subject']; $subject = $_POST['subject'];
@@ -105,7 +105,7 @@ 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']['noreceipients']; $successmessage = $lng['message']['norecipients'];
} else { } else {
$successmessage = str_replace('%s', $sentitems, $lng['message']['success']); $successmessage = str_replace('%s', $sentitems, $lng['message']['success']);
} }
@@ -116,12 +116,12 @@ if ($page == 'message') {
} }
$action = ''; $action = '';
$receipients = ''; $recipients = '';
if ($userinfo['customers_see_all'] == '1') { if ($userinfo['customers_see_all'] == '1') {
$receipients .= \Froxlor\UI\HTML::makeoption($lng['panel']['reseller'], 0); $recipients .= \Froxlor\UI\HTML::makeoption($lng['panel']['reseller'], 0);
} }
$receipients .= \Froxlor\UI\HTML::makeoption($lng['panel']['customer'], 1); $recipients .= \Froxlor\UI\HTML::makeoption($lng['panel']['customer'], 1);
eval("echo \"" . \Froxlor\UI\Template::getTemplate('message/message') . "\";"); eval("echo \"" . \Froxlor\UI\Template::getTemplate('message/message') . "\";");
} }

View File

@@ -22,7 +22,7 @@ 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, "reseted OPcache"); $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "reset OPcache");
header('Location: ' . $linker->getLink(array( header('Location: ' . $linker->getLink(array(
'section' => 'opcacheinfo', 'section' => 'opcacheinfo',
'page' => 'showinfo' 'page' => 'showinfo'

View File

@@ -56,6 +56,26 @@ 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;
@@ -76,14 +96,7 @@ if ($page == 'overview' || $page == 'customers') {
'dec' => 0 'dec' => 0
); );
$customer_name_list_stmt = Database::prepare(" Database::pexecute($customer_name_list_stmt, $params);
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)) {
@@ -104,11 +117,6 @@ if ($page == 'overview' || $page == 'customers') {
'dec' => '-' 'dec' => '-'
); );
$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");
Database::pexecute($traffic_list_stmt, array( Database::pexecute($traffic_list_stmt, array(
'year' => (date("Y") - $years), 'year' => (date("Y") - $years),
'id' => $customer_name['customerid'] 'id' => $customer_name['customerid']

View File

@@ -1,4 +1,6 @@
<?php <?php
use voku\helper\AntiXSS;
require __DIR__ . '/vendor/autoload.php'; require __DIR__ . '/vendor/autoload.php';
require \Froxlor\Froxlor::getInstallDir() . '/lib/tables.inc.php'; require \Froxlor\Froxlor::getInstallDir() . '/lib/tables.inc.php';
@@ -30,6 +32,12 @@ if (is_null($decoded_request)) {
json_response(400, "Invalid JSON"); json_response(400, "Invalid JSON");
} }
/**
* check for xss attempts and clean request
*/
$antiXss = new AntiXSS();
$request = $antiXss->xss_clean($request);
// validate content // validate content
try { try {
$decoded_request = stripcslashes_deep($decoded_request); $decoded_request = stripcslashes_deep($decoded_request);

View File

@@ -127,7 +127,7 @@ if ($action == 'delete') {
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed api::api_keys"); $log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed api::api_keys");
// select all my (accessable) certificates // select all my (accessible) certificates
$keys_stmt_query = "SELECT ak.*, c.loginname, a.loginname as adminname $keys_stmt_query = "SELECT ak.*, c.loginname, a.loginname as adminname
FROM `" . TABLE_API_KEYS . "` ak FROM `" . TABLE_API_KEYS . "` ak
LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` c ON `c`.`customerid` = `ak`.`customerid` LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` c ON `c`.`customerid` = `ak`.`customerid`

View File

@@ -6,21 +6,20 @@
<property name="pdepend" value="${basedir}/vendor/bin/pdepend" /> <property name="pdepend" value="${basedir}/vendor/bin/pdepend" />
<property name="phpcpd" value="${basedir}/vendor/bin/phpcpd" /> <property name="phpcpd" value="${basedir}/vendor/bin/phpcpd" />
<property name="phpcs" value="${basedir}/vendor/bin/phpcs" /> <property name="phpcs" value="${basedir}/vendor/bin/phpcs" />
<property name="phpdox" value="${basedir}/vendor/bin/phpdox" />
<property name="phploc" value="${basedir}/vendor/bin/phploc" /> <property name="phploc" value="${basedir}/vendor/bin/phploc" />
<property name="phpmd" value="${basedir}/vendor/bin/phpmd" /> <property name="phpmd" value="${basedir}/vendor/bin/phpmd" />
<property name="phpunit" value="${basedir}/vendor/bin/phpunit" /> <property name="phpunit" value="${basedir}/vendor/bin/phpunit" />
<target name="full-build" <target name="full-build"
depends="prepare,composer,static-analysis,phpunit,phpdox,-check-failure" depends="prepare,composer,static-analysis,phpunit,-check-failure"
description="Performs static analysis, runs the tests, and generates project documentation" /> description="Performs static analysis, runs the tests, and generates project documentation" />
<target name="full-build-parallel" <target name="full-build-parallel"
depends="prepare,composer,static-analysis-parallel,phpunit,phpdox,-check-failure" 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" /> description="Performs static analysis (executing the tools in parallel), runs the tests, and generates project documentation" />
<target name="quick-build" <target name="quick-build"
depends="prepare,composer,lint,phpunit-no-coverage" depends="prepare,composer,lint,phpunit-no-coverage,-check-failure"
description="Performs a lint check and runs the tests (without generating code coverage reports)" /> description="Performs a lint check and runs the tests (without generating code coverage reports)" />
<target name="static-analysis" <target name="static-analysis"
@@ -49,7 +48,6 @@
<delete dir="${basedir}/build/coverage" /> <delete dir="${basedir}/build/coverage" />
<delete dir="${basedir}/build/logs" /> <delete dir="${basedir}/build/logs" />
<delete dir="${basedir}/build/pdepend" /> <delete dir="${basedir}/build/pdepend" />
<delete dir="${basedir}/build/phpdox" />
<property name="clean.done" value="true" /> <property name="clean.done" value="true" />
</target> </target>
@@ -59,7 +57,6 @@
<mkdir dir="${basedir}/build/coverage" /> <mkdir dir="${basedir}/build/coverage" />
<mkdir dir="${basedir}/build/logs" /> <mkdir dir="${basedir}/build/logs" />
<mkdir dir="${basedir}/build/pdepend" /> <mkdir dir="${basedir}/build/pdepend" />
<mkdir dir="${basedir}/build/phpdox" />
<property name="prepare.done" value="true" /> <property name="prepare.done" value="true" />
</target> </target>
@@ -257,7 +254,7 @@
<target name="phpunit-no-coverage" unless="phpunit.done" <target name="phpunit-no-coverage" unless="phpunit.done"
depends="composer" depends="composer"
description="Run unit tests with PHPUnit (without generating code coverage reports)"> description="Run unit tests with PHPUnit (without generating code coverage reports)">
<exec executable="${phpunit}" failonerror="true" <exec executable="${phpunit}" failonerror="true" resultproperty="result.phpunit"
taskname="phpunit"> taskname="phpunit">
<arg value="--configuration" /> <arg value="--configuration" />
<arg path="${basedir}/phpunit.xml" /> <arg path="${basedir}/phpunit.xml" />
@@ -269,18 +266,6 @@
<property name="phpunit.done" value="true" /> <property name="phpunit.done" value="true" />
</target> </target>
<target name="phpdox" unless="phpdox.done"
depends="phploc-ci,phpcs-ci,phpcompat-ci,phpmd-ci"
description="Generate project documentation using phpDox">
<exec executable="${phpdox}" dir="${basedir}/build"
taskname="phpdox">
<arg value="--file" />
<arg path="${basedir}/phpdox.xml" />
</exec>
<property name="phpdox.done" value="true" />
</target>
<target name="-check-failure"> <target name="-check-failure">
<fail message="PHPUnit did not finish successfully"> <fail message="PHPUnit did not finish successfully">
<condition> <condition>

View File

@@ -25,12 +25,12 @@
"issues": "https://github.com/Froxlor/Froxlor/issues", "issues": "https://github.com/Froxlor/Froxlor/issues",
"forum": "https://forum.froxlor.org/", "forum": "https://forum.froxlor.org/",
"wiki": "https://github.com/Froxlor/Froxlor/wiki", "wiki": "https://github.com/Froxlor/Froxlor/wiki",
"irc": "irc://chat.freenode.net/froxlor", "irc": "irc://irc.libera.chat/froxlor",
"source": "https://github.com/Froxlor/Froxlor", "source": "https://github.com/Froxlor/Froxlor",
"docs": "https://github.com/Froxlor/Froxlor/wiki" "docs": "https://github.com/Froxlor/Froxlor/wiki"
}, },
"require": { "require": {
"php": ">=7.0", "php": ">=7.1",
"ext-session": "*", "ext-session": "*",
"ext-ctype": "*", "ext-ctype": "*",
"ext-pdo": "*", "ext-pdo": "*",
@@ -43,22 +43,24 @@
"ext-curl": "*", "ext-curl": "*",
"ext-json": "*", "ext-json": "*",
"ext-openssl": "*", "ext-openssl": "*",
"ext-fileinfo": "*",
"phpmailer/phpmailer": "~6.0", "phpmailer/phpmailer": "~6.0",
"monolog/monolog": "^1.24", "monolog/monolog": "^1.24",
"robthree/twofactorauth": "^1.6", "robthree/twofactorauth": "^1.6",
"froxlor/idna-convert-legacy": "^2.1" "froxlor/idna-convert-legacy": "^2.1",
"voku/anti-xss": "^4.1"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "8.4.1", "phpunit/phpunit": "^9",
"php": ">=7.3", "php": ">=7.3",
"ext-pcntl": "*", "ext-pcntl": "*",
"phpcompatibility/php-compatibility": "*", "phpcompatibility/php-compatibility": "*",
"squizlabs/php_codesniffer": "*", "squizlabs/php_codesniffer": "*",
"pdepend/pdepend": "^2.5", "pdepend/pdepend": "^2.9",
"sebastian/phpcpd": "^4.1", "sebastian/phpcpd": "^6.0",
"theseer/phpdox": "^0.12.0", "phploc/phploc": "^7.0",
"phploc/phploc": "^5.0", "phpmd/phpmd": "^2.10",
"phpmd/phpmd": "^2.6" "phpunit/php-timer" : "^5"
}, },
"suggest": { "suggest": {
"ext-bcmath": "*", "ext-bcmath": "*",

3027
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -133,10 +133,10 @@ if ($page == 'overview') {
FROM `" . TABLE_PANEL_DOMAINS . "` FROM `" . TABLE_PANEL_DOMAINS . "`
WHERE `customerid`= :cid AND `isemaildomain` = '1' WHERE `customerid`= :cid AND `isemaildomain` = '1'
"); ");
$result = Database::pexecute_first($result_stmt, array( $result2 = Database::pexecute_first($result_stmt, array(
"cid" => $userinfo['customerid'] "cid" => $userinfo['customerid']
)); ));
$emaildomains_count = $result['emaildomains']; $emaildomains_count = $result2['emaildomains'];
eval("echo \"" . \Froxlor\UI\Template::getTemplate("email/emails") . "\";"); eval("echo \"" . \Froxlor\UI\Template::getTemplate("email/emails") . "\";");
} elseif ($action == 'delete' && $id != 0) { } elseif ($action == 'delete' && $id != 0) {
@@ -153,7 +153,8 @@ if ($page == 'overview') {
if (isset($_POST['send']) && $_POST['send'] == 'send') { if (isset($_POST['send']) && $_POST['send'] == 'send') {
try { try {
Emails::getLocal($userinfo, array( Emails::getLocal($userinfo, array(
'id' => $id 'id' => $id,
'delete_userfiles' => ($_POST['delete_userfiles'] ?? 0)
))->delete(); ))->delete();
} catch (Exception $e) { } catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage()); \Froxlor\UI\Response::dynamic_error($e->getMessage());

View File

@@ -93,22 +93,30 @@ if ($page == 'overview') {
'cid' => $userinfo['customerid'] 'cid' => $userinfo['customerid']
)); ));
if ($usages) // get everything in bytes for the percentage calculation on the dashboard
{ $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'));
$userinfo['total_used'] = round(($usages['webspace'] + $usages['mail'] + $usages['mysql']) / 1024, Settings::Get('panel.decimal_places')); if ($usages) {
$userinfo['diskspace_used'] = \Froxlor\PhpHelper::sizeReadable($usages['webspace'] * 1024, null, 'bi');
$userinfo['mailspace_used'] = \Froxlor\PhpHelper::sizeReadable($usages['mail'] * 1024, null, 'bi');
$userinfo['dbspace_used'] = \Froxlor\PhpHelper::sizeReadable($usages['mysql'] * 1024, null, 'bi');
$userinfo['total_used'] = \Froxlor\PhpHelper::sizeReadable(($usages['webspace'] + $usages['mail'] + $usages['mysql']) * 1024, null, 'bi');
$userinfo['diskspace_bytes_used'] = $usages['webspace'] * 1024;
$userinfo['total_bytes_used'] = ($usages['webspace'] + $usages['mail'] + $usages['mysql']) * 1024;
} else { } else {
$userinfo['diskspace_used'] = 0; $userinfo['diskspace_used'] = 0;
$userinfo['mailspace_used'] = 0; $userinfo['mailspace_used'] = 0;
$userinfo['dbspace_used'] = 0; $userinfo['dbspace_used'] = 0;
$userinfo['total_used'] = 0; $userinfo['total_used'] = 0;
$userinfo['diskspace_bytes_used'] = 0;
$userinfo['total_bytes_used'] = 0;
} }
$userinfo['diskspace'] = round($userinfo['diskspace'] / 1024, Settings::Get('panel.decimal_places')); $userinfo['diskspace'] = ($userinfo['diskspace'] > -1) ? \Froxlor\PhpHelper::sizeReadable($userinfo['diskspace'] * 1024, null, 'bi') : - 1;
$userinfo['traffic'] = round($userinfo['traffic'] / (1024 * 1024), Settings::Get('panel.decimal_places')); $userinfo['traffic'] = ($userinfo['traffic'] > -1) ? \Froxlor\PhpHelper::sizeReadable($userinfo['traffic'] * 1024, null, 'bi') : - 1;
$userinfo['traffic_used'] = round($userinfo['traffic_used'] / (1024 * 1024), Settings::Get('panel.decimal_places')); $userinfo['traffic_used'] = \Froxlor\PhpHelper::sizeReadable($userinfo['traffic_used'] * 1024, null, 'bi');
$userinfo = \Froxlor\PhpHelper::strReplaceArray('-1', $lng['customer']['unlimited'], $userinfo, 'diskspace traffic mysqls emails email_accounts email_forwarders email_quota ftps subdomains'); $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']) : '';
@@ -128,14 +136,20 @@ if ($page == 'overview') {
eval("echo \"" . \Froxlor\UI\Template::getTemplate('index/index') . "\";"); eval("echo \"" . \Froxlor\UI\Template::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 = \Froxlor\Validate\Validate::validate($_POST['old_password'], 'old password');
if (! \Froxlor\System\Crypt::validatePasswordLogin($userinfo, $old_password, TABLE_PANEL_CUSTOMERS, 'customerid')) { if (! \Froxlor\System\Crypt::validatePasswordLogin($userinfo, $old_password, TABLE_PANEL_CUSTOMERS, 'customerid')) {
\Froxlor\UI\Response::standard_error('oldpasswordnotcorrect'); \Froxlor\UI\Response::standard_error('oldpasswordnotcorrect');
} }
try {
$new_password = \Froxlor\System\Crypt::validatePassword($_POST['new_password'], 'new password'); $new_password = \Froxlor\System\Crypt::validatePassword($_POST['new_password'], 'new password');
$new_password_confirm = \Froxlor\System\Crypt::validatePassword($_POST['new_password_confirm'], 'new password confirm'); $new_password_confirm = \Froxlor\System\Crypt::validatePassword($_POST['new_password_confirm'], 'new password confirm');
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
if ($old_password == '') { if ($old_password == '') {
\Froxlor\UI\Response::standard_error(array( \Froxlor\UI\Response::standard_error(array(

View File

@@ -85,10 +85,12 @@ if ($page == 'overview') {
$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");
Database::pexecute($mbdata_stmt, array( $mbdata = Database::pexecute_first($mbdata_stmt, array(
"table_schema" => $row['databasename'] "table_schema" => $row['databasename']
)); ));
$mbdata = $mbdata_stmt->fetch(PDO::FETCH_ASSOC); if (!$mbdata) {
$mbdata = array('MB' => 0);
}
$row['size'] = \Froxlor\PhpHelper::sizeReadable($mbdata['MB'], 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s'); $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') . "\";"); eval("\$mysqls.=\"" . \Froxlor\UI\Template::getTemplate('mysql/mysqls_database') . "\";");
$count ++; $count ++;

View File

@@ -86,22 +86,18 @@ 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['httptext'] = round($http / 1024, Settings::Get('panel.decimal_places')) . " MiB (HTTP)"; $traf['ftp'] = round($ftp / 1024, Settings::Get('panel.decimal_places'));
$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)");
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') . "\";"); 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'];
} }
@@ -142,22 +138,18 @@ 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)");
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') . "\";"); eval("\$traffic.=\"" . \Froxlor\UI\Template::getTemplate('traffic/traffic_traffic') . "\";");
} }
@@ -167,3 +159,12 @@ if (! is_null($month) && ! is_null($year)) {
eval("echo \"" . \Froxlor\UI\Template::getTemplate('traffic/traffic') . "\";"); eval("echo \"" . \Froxlor\UI\Template::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

@@ -19,7 +19,6 @@ if (! defined('AREA')) {
* *
*/ */
use Froxlor\Database\Database;
use Froxlor\Api\Commands\DomainZones as DomainZones; 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
@@ -36,18 +35,6 @@ $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 = \Froxlor\Dns\Dns::getAllowedDomainEntry($domain_id, AREA, $userinfo);
// select all entries
try {
// get list
$json_result = DomainZones::getLocal($userinfo, [
'id' => $domain_id
])->listing();
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$dom_entries = $result['list'];
$errors = ""; $errors = "";
$success_message = ""; $success_message = "";
@@ -63,8 +50,9 @@ if ($action == 'add_record' && ! empty($_POST)) {
'ttl' => $ttl 'ttl' => $ttl
))->add(); ))->add();
$success_message = $lng['success']['dns_record_added']; $success_message = $lng['success']['dns_record_added'];
$record = $prio = $content = "";
} catch (Exception $e) { } catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage()); $errors = str_replace("\n", "<br>", $e->getMessage());
} }
} elseif ($action == 'delete') { } elseif ($action == 'delete') {
// remove entry // remove entry
@@ -75,25 +63,25 @@ if ($action == 'add_record' && ! empty($_POST)) {
'entry_id' => $entry_id, 'entry_id' => $entry_id,
'id' => $domain_id 'id' => $domain_id
))->delete(); ))->delete();
// success message (inline)
$success_message = $lng['success']['dns_record_deleted'];
} catch (Exception $e) { } catch (Exception $e) {
$errors = str_replace("\n", "<br>", $e->getMessage()); $errors = str_replace("\n", "<br>", $e->getMessage());
} }
}
}
if (empty($errors)) { // select all entries
// remove deleted entry from internal data array (no reread of DB necessary) try {
$_t = $dom_entries; // get list
foreach ($_t as $idx => $entry) { $json_result = DomainZones::getLocal($userinfo, [
if ($entry['id'] == $entry_id) { 'id' => $domain_id
unset($dom_entries[$idx]); ])->listing();
break; } catch (Exception $e) {
} \Froxlor\UI\Response::dynamic_error($e->getMessage());
}
unset($_t);
// success message (inline)
$success_message = $lng['success']['dns_record_deleted'];
}
}
} }
$result = json_decode($json_result, true)['data'];
$dom_entries = $result['list'];
// show editor // show editor
$record_list = ""; $record_list = "";

View File

@@ -28,6 +28,12 @@ if ($action == '') {
} }
if (session_status() == PHP_SESSION_NONE) { if (session_status() == PHP_SESSION_NONE) {
ini_set("session.name", "s");
ini_set("url_rewriter.tags", "");
ini_set("session.use_cookies", false);
ini_set("session.cookie_httponly", true);
ini_set("session.cookie_secure", $is_ssl);
session_id('login');
session_start(); session_start();
} }
@@ -114,7 +120,7 @@ if ($action == '2fa_entercode') {
)); ));
$row = $stmt->fetch(PDO::FETCH_ASSOC); $row = $stmt->fetch(PDO::FETCH_ASSOC);
if ($row['customer'] == $loginname) { if ($row && $row['customer'] == $loginname) {
$table = "`" . TABLE_PANEL_CUSTOMERS . "`"; $table = "`" . TABLE_PANEL_CUSTOMERS . "`";
$uid = 'customerid'; $uid = 'customerid';
$adminsession = '0'; $adminsession = '0';
@@ -142,7 +148,7 @@ if ($action == '2fa_entercode') {
"loginname" => $loginname "loginname" => $loginname
)); ));
$row3 = $stmt->fetch(PDO::FETCH_ASSOC); $row3 = $stmt->fetch(PDO::FETCH_ASSOC);
if ($row3['customer'] == $loginname) { if ($row3 && $row3['customer'] == $loginname) {
$table = "`" . TABLE_PANEL_CUSTOMERS . "`"; $table = "`" . TABLE_PANEL_CUSTOMERS . "`";
$uid = 'customerid'; $uid = 'customerid';
$adminsession = '0'; $adminsession = '0';
@@ -181,7 +187,7 @@ if ($action == '2fa_entercode') {
$row = $stmt->fetch(PDO::FETCH_ASSOC); $row = $stmt->fetch(PDO::FETCH_ASSOC);
} }
if ($row['admin'] == $loginname) { if ($row && $row['admin'] == $loginname) {
$table = "`" . TABLE_PANEL_ADMINS . "`"; $table = "`" . TABLE_PANEL_ADMINS . "`";
$uid = 'adminid'; $uid = 'adminid';
$adminsession = '1'; $adminsession = '1';
@@ -669,7 +675,7 @@ function finishLogin($userinfo)
global $version, $dbversion, $remote_addr, $http_user_agent, $languages; global $version, $dbversion, $remote_addr, $http_user_agent, $languages;
if (isset($userinfo['userid']) && $userinfo['userid'] != '') { if (isset($userinfo['userid']) && $userinfo['userid'] != '') {
$s = md5(uniqid(microtime(), 1)); $s = \Froxlor\Froxlor::genSessionId();
if (isset($_POST['language'])) { if (isset($_POST['language'])) {
$language = \Froxlor\Validate\Validate::validate($_POST['language'], 'language'); $language = \Froxlor\Validate\Validate::validate($_POST['language'], 'language');

View File

@@ -15,10 +15,10 @@ CREATE TABLE `ftp_groups` (
DROP TABLE IF EXISTS `ftp_users`; DROP TABLE IF EXISTS `ftp_users`;
CREATE TABLE `ftp_users` ( CREATE TABLE `ftp_users` (
`id` int(20) NOT NULL auto_increment, `id` int(20) NOT NULL auto_increment,
`username` varchar(255) NOT NULL default '', `username` varchar(255) NOT NULL,
`uid` int(5) NOT NULL default '0', `uid` int(5) NOT NULL default '0',
`gid` int(5) NOT NULL default '0', `gid` int(5) NOT NULL default '0',
`password` varchar(128) NOT NULL default '', `password` varchar(128) NOT NULL,
`homedir` varchar(255) NOT NULL default '', `homedir` varchar(255) NOT NULL default '',
`shell` varchar(255) NOT NULL default '/bin/false', `shell` varchar(255) NOT NULL default '/bin/false',
`login_enabled` enum('N','Y') NOT NULL default 'N', `login_enabled` enum('N','Y') NOT NULL default 'N',
@@ -71,6 +71,7 @@ CREATE TABLE `mail_virtual` (
`customerid` int(11) NOT NULL default '0', `customerid` int(11) NOT NULL default '0',
`popaccountid` int(11) NOT NULL default '0', `popaccountid` int(11) NOT NULL default '0',
`iscatchall` tinyint(1) unsigned NOT NULL default '0', `iscatchall` tinyint(1) unsigned NOT NULL default '0',
`description` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `email` (`email`) KEY `email` (`email`)
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci; ) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
@@ -90,8 +91,8 @@ CREATE TABLE `panel_activation` (
DROP TABLE IF EXISTS `panel_admins`; DROP TABLE IF EXISTS `panel_admins`;
CREATE TABLE `panel_admins` ( CREATE TABLE `panel_admins` (
`adminid` int(11) unsigned NOT NULL auto_increment, `adminid` int(11) unsigned NOT NULL auto_increment,
`loginname` varchar(50) NOT NULL default '', `loginname` varchar(50) NOT NULL,
`password` varchar(255) NOT NULL default '', `password` varchar(255) NOT NULL,
`name` varchar(255) NOT NULL default '', `name` varchar(255) NOT NULL default '',
`email` varchar(255) NOT NULL default '', `email` varchar(255) NOT NULL default '',
`def_language` varchar(100) NOT NULL default '', `def_language` varchar(100) NOT NULL default '',
@@ -142,7 +143,7 @@ CREATE TABLE `panel_admins` (
DROP TABLE IF EXISTS `panel_customers`; DROP TABLE IF EXISTS `panel_customers`;
CREATE TABLE `panel_customers` ( CREATE TABLE `panel_customers` (
`customerid` int(11) unsigned NOT NULL auto_increment, `customerid` int(11) unsigned NOT NULL auto_increment,
`loginname` varchar(50) NOT NULL default '', `loginname` varchar(50) NOT NULL,
`password` varchar(255) NOT NULL default '', `password` varchar(255) NOT NULL default '',
`adminid` int(11) unsigned NOT NULL default '0', `adminid` int(11) unsigned NOT NULL default '0',
`name` varchar(255) NOT NULL default '', `name` varchar(255) NOT NULL default '',
@@ -223,7 +224,7 @@ CREATE TABLE `panel_databases` (
DROP TABLE IF EXISTS `panel_domains`; DROP TABLE IF EXISTS `panel_domains`;
CREATE TABLE `panel_domains` ( CREATE TABLE `panel_domains` (
`id` int(11) unsigned NOT NULL auto_increment, `id` int(11) unsigned NOT NULL auto_increment,
`domain` varchar(255) NOT NULL default '', `domain` varchar(255) NOT NULL,
`domain_ace` varchar(255) NOT NULL default '', `domain_ace` varchar(255) NOT NULL default '',
`adminid` int(11) unsigned NOT NULL default '0', `adminid` int(11) unsigned NOT NULL default '0',
`customerid` int(11) unsigned NOT NULL default '0', `customerid` int(11) unsigned NOT NULL default '0',
@@ -269,12 +270,13 @@ CREATE TABLE `panel_domains` (
`writeaccesslog` tinyint(1) DEFAULT '1', `writeaccesslog` tinyint(1) DEFAULT '1',
`writeerrorlog` tinyint(1) DEFAULT '1', `writeerrorlog` tinyint(1) DEFAULT '1',
`override_tls` tinyint(1) DEFAULT '0', `override_tls` tinyint(1) DEFAULT '0',
`ssl_protocols` text, `ssl_protocols` varchar(255) NOT NULL DEFAULT '',
`ssl_cipher_list` text, `ssl_cipher_list` varchar(500) NOT NULL DEFAULT '',
`tlsv13_cipher_list` text, `tlsv13_cipher_list` varchar(500) NOT NULL DEFAULT '',
`ssl_enabled` tinyint(1) DEFAULT '1', `ssl_enabled` tinyint(1) DEFAULT '1',
`ssl_honorcipherorder` tinyint(1) DEFAULT '0', `ssl_honorcipherorder` tinyint(1) DEFAULT '0',
`ssl_sessiontickets` tinyint(1) DEFAULT '1', `ssl_sessiontickets` tinyint(1) DEFAULT '1',
`description` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `customerid` (`customerid`), KEY `customerid` (`customerid`),
KEY `parentdomain` (`parentdomainid`), KEY `parentdomain` (`parentdomainid`),
@@ -286,7 +288,7 @@ CREATE TABLE `panel_domains` (
DROP TABLE IF EXISTS `panel_ipsandports`; DROP TABLE IF EXISTS `panel_ipsandports`;
CREATE TABLE `panel_ipsandports` ( CREATE TABLE `panel_ipsandports` (
`id` int(11) unsigned NOT NULL auto_increment, `id` int(11) unsigned NOT NULL auto_increment,
`ip` varchar(39) NOT NULL default '', `ip` varchar(39) NOT NULL,
`port` int(5) NOT NULL default '80', `port` int(5) NOT NULL default '80',
`listen_statement` tinyint(1) NOT NULL default '0', `listen_statement` tinyint(1) NOT NULL default '0',
`namevirtualhost_statement` tinyint(1) NOT NULL default '0', `namevirtualhost_statement` tinyint(1) NOT NULL default '0',
@@ -387,6 +389,7 @@ INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES
('dkim', 'dkim_domains', 'domains'), ('dkim', 'dkim_domains', 'domains'),
('dkim', 'dkim_dkimkeys', 'dkim-keys.conf'), ('dkim', 'dkim_dkimkeys', 'dkim-keys.conf'),
('dkim', 'dkimrestart_command', '/etc/init.d/dkim-filter restart'), ('dkim', 'dkimrestart_command', '/etc/init.d/dkim-filter restart'),
('dkim', 'privkeysuffix', '.priv'),
('admin', 'show_news_feed', '0'), ('admin', 'show_news_feed', '0'),
('admin', 'show_version_login', '0'), ('admin', 'show_version_login', '0'),
('admin', 'show_version_footer', '0'), ('admin', 'show_version_footer', '0'),
@@ -554,6 +557,7 @@ opcache.interned_strings_buffer'),
('system', 'ssl_cert_file', '/etc/apache2/apache2.pem'), ('system', 'ssl_cert_file', '/etc/apache2/apache2.pem'),
('system', 'use_ssl', '0'), ('system', 'use_ssl', '0'),
('system', 'default_vhostconf', ''), ('system', 'default_vhostconf', ''),
('system', 'default_sslvhostconf', ''),
('system', 'mail_quota_enabled', '0'), ('system', 'mail_quota_enabled', '0'),
('system', 'mail_quota', '100'), ('system', 'mail_quota', '100'),
('system', 'webalizer_enabled', '1'), ('system', 'webalizer_enabled', '1'),
@@ -607,6 +611,7 @@ opcache.interned_strings_buffer'),
('system', 'documentroot_use_default_value', '0'), ('system', 'documentroot_use_default_value', '0'),
('system', 'passwordcryptfunc', '3'), ('system', 'passwordcryptfunc', '3'),
('system', 'axfrservers', ''), ('system', 'axfrservers', ''),
('system', 'powerdns_mode', 'Native'),
('system', 'customer_ssl_path', '/etc/ssl/froxlor-custom/'), ('system', 'customer_ssl_path', '/etc/ssl/froxlor-custom/'),
('system', 'allow_error_report_admin', '1'), ('system', 'allow_error_report_admin', '1'),
('system', 'allow_error_report_customer', '0'), ('system', 'allow_error_report_customer', '0'),
@@ -624,7 +629,7 @@ opcache.interned_strings_buffer'),
('system', 'apacheitksupport', '0'), ('system', 'apacheitksupport', '0'),
('system', 'leprivatekey', 'unset'), ('system', 'leprivatekey', 'unset'),
('system', 'lepublickey', 'unset'), ('system', 'lepublickey', 'unset'),
('system', 'letsencryptca', 'production'), ('system', 'letsencryptca', 'letsencrypt'),
('system', 'letsencryptcountrycode', 'DE'), ('system', 'letsencryptcountrycode', 'DE'),
('system', 'letsencryptstate', 'Hessen'), ('system', 'letsencryptstate', 'Hessen'),
('system', 'letsencryptchallengepath', '/var/www/froxlor'), ('system', 'letsencryptchallengepath', '/var/www/froxlor'),
@@ -655,7 +660,7 @@ opcache.interned_strings_buffer'),
('system', 'leaccount', ''), ('system', 'leaccount', ''),
('system', 'nssextrausers', '0'), ('system', 'nssextrausers', '0'),
('system', 'le_domain_dnscheck', '1'), ('system', 'le_domain_dnscheck', '1'),
('system', 'ssl_protocols', 'TLSv1,TLSv1.2'), ('system', 'ssl_protocols', 'TLSv1.2'),
('system', 'tlsv13_cipher_list', ''), ('system', 'tlsv13_cipher_list', ''),
('system', 'honorcipherorder', '0'), ('system', 'honorcipherorder', '0'),
('system', 'sessiontickets', '1'), ('system', 'sessiontickets', '1'),
@@ -670,6 +675,13 @@ opcache.interned_strings_buffer'),
('system', 'froxloraliases', ''), ('system', 'froxloraliases', ''),
('system', 'apply_specialsettings_default', '1'), ('system', 'apply_specialsettings_default', '1'),
('system', 'apply_phpconfigs_default', '1'), ('system', 'apply_phpconfigs_default', '1'),
('system', 'hide_incompatible_settings', '0'),
('system', 'include_default_vhostconf', '0'),
('system', 'soaemail', ''),
('system', 'domaindefaultalias', '0'),
('system', 'createstdsubdom_default', '1'),
('system', 'froxlorusergroup', ''),
('system', 'froxlorusergroup_gid', ''),
('api', 'enabled', '0'), ('api', 'enabled', '0'),
('2fa', 'enabled', '1'), ('2fa', 'enabled', '1'),
('panel', 'decimal_places', '4'), ('panel', 'decimal_places', '4'),
@@ -682,7 +694,6 @@ opcache.interned_strings_buffer'),
('panel', 'paging', '20'), ('panel', 'paging', '20'),
('panel', 'natsorting', '1'), ('panel', 'natsorting', '1'),
('panel', 'sendalternativemail', '0'), ('panel', 'sendalternativemail', '0'),
('panel', 'no_robots', '1'),
('panel', 'allow_domain_change_admin', '0'), ('panel', 'allow_domain_change_admin', '0'),
('panel', 'allow_domain_change_customer', '0'), ('panel', 'allow_domain_change_customer', '0'),
('panel', 'frontend', 'froxlor'), ('panel', 'frontend', 'froxlor'),
@@ -704,8 +715,15 @@ opcache.interned_strings_buffer'),
('panel', 'password_special_char', '!?<>§$%+#=@'), ('panel', 'password_special_char', '!?<>§$%+#=@'),
('panel', 'customer_hide_options', ''), ('panel', 'customer_hide_options', ''),
('panel', 'is_configured', '0'), ('panel', 'is_configured', '0'),
('panel', 'version', '0.10.17'), ('panel', 'imprint_url', ''),
('panel', 'db_version', '202005150'); ('panel', 'terms_url', ''),
('panel', 'privacy_url', ''),
('panel', 'logo_image_header', ''),
('panel', 'logo_image_login', ''),
('panel', 'logo_overridetheme', '0'),
('panel', 'logo_overridecustom', '0'),
('panel', 'version', '0.10.29.1'),
('panel', 'db_version', '202109040');
DROP TABLE IF EXISTS `panel_tasks`; DROP TABLE IF EXISTS `panel_tasks`;
@@ -786,23 +804,6 @@ CREATE TABLE `panel_diskspace` (
DROP TABLE IF EXISTS `panel_diskspace_admins`;
CREATE TABLE `panel_diskspace_admins` (
`id` int(11) unsigned NOT NULL auto_increment,
`adminid` int(11) unsigned NOT NULL default '0',
`year` int(4) unsigned zerofill NOT NULL default '0000',
`month` int(2) unsigned zerofill NOT NULL default '00',
`day` int(2) unsigned zerofill NOT NULL default '00',
`stamp` int(11) unsigned NOT NULL default '0',
`webspace` bigint(30) unsigned NOT NULL default '0',
`mail` bigint(30) unsigned NOT NULL default '0',
`mysql` bigint(30) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
KEY `adminid` (`adminid`)
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci;
DROP TABLE IF EXISTS `panel_languages`; DROP TABLE IF EXISTS `panel_languages`;
CREATE TABLE `panel_languages` ( CREATE TABLE `panel_languages` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
@@ -821,7 +822,8 @@ INSERT INTO `panel_languages` (`id`, `language`, `iso`, `file`) VALUES
(4, 'Portugu&ecirc;s', 'pt', 'lng/portugues.lng.php'), (4, 'Portugu&ecirc;s', 'pt', 'lng/portugues.lng.php'),
(5, 'Italiano', 'it', 'lng/italian.lng.php'), (5, 'Italiano', 'it', 'lng/italian.lng.php'),
(6, 'Nederlands', 'nl', 'lng/dutch.lng.php'), (6, 'Nederlands', 'nl', 'lng/dutch.lng.php'),
(7, 'Svenska', 'sv', 'lng/swedish.lng.php'); (7, 'Svenska', 'sv', 'lng/swedish.lng.php'),
(8, '&#268;esk&aacute; republika', 'cs', 'lng/czech.lng.php');
DROP TABLE IF EXISTS `panel_syslog`; DROP TABLE IF EXISTS `panel_syslog`;

View File

@@ -123,7 +123,7 @@ class FroxlorInstall
if ((isset($_POST['installstep']) && $_POST['installstep'] == '1') || (isset($_GET['check']) && $_GET['check'] == '1')) { if ((isset($_POST['installstep']) && $_POST['installstep'] == '1') || (isset($_GET['check']) && $_GET['check'] == '1')) {
$pagetitle = $this->_lng['install']['title']; $pagetitle = $this->_lng['install']['title'];
if ($this->_checkPostData()) { if ($this->_checkPostData()) {
// ceck data and create userdata etc.etc.etc. // check data and create userdata etc.etc.etc.
$result = $this->_doInstall(); $result = $this->_doInstall();
} elseif (isset($_GET['check']) && $_GET['check'] == '1') { } elseif (isset($_GET['check']) && $_GET['check'] == '1') {
// gather data // gather data
@@ -159,13 +159,17 @@ class FroxlorInstall
$this->_guessServerName(); $this->_guessServerName();
$this->_guessServerIP(); $this->_guessServerIP();
$this->_guessWebserver(); $this->_guessWebserver();
$this->_guessDistribution();
$this->_getPostField('mysql_host', '127.0.0.1'); $this->_getPostField('mysql_host', '127.0.0.1');
$this->_getPostField('mysql_database', 'froxlor'); $this->_getPostField('mysql_database', 'froxlor');
$this->_getPostField('mysql_forcecreate', '0');
$this->_getPostField('mysql_unpriv_user', 'froxlor'); $this->_getPostField('mysql_unpriv_user', 'froxlor');
$this->_getPostField('mysql_unpriv_pass'); $this->_getPostField('mysql_unpriv_pass');
$this->_getPostField('mysql_root_user', 'root'); $this->_getPostField('mysql_root_user', 'root');
$this->_getPostField('mysql_root_pass'); $this->_getPostField('mysql_root_pass');
$this->_getPostField('mysql_ssl_ca_file');
$this->_getPostField('mysql_ssl_verify_server_certificate', 0);
$this->_getPostField('admin_user', 'admin'); $this->_getPostField('admin_user', 'admin');
$this->_getPostField('admin_pass1'); $this->_getPostField('admin_pass1');
$this->_getPostField('admin_pass2'); $this->_getPostField('admin_pass2');
@@ -211,6 +215,12 @@ class FroxlorInstall
$options = array( $options = array(
'PDO::MYSQL_ATTR_INIT_COMMAND' => 'SET names utf8' 'PDO::MYSQL_ATTR_INIT_COMMAND' => 'SET names utf8'
); );
if (!empty($this->_data['mysql_ssl_ca_file'])) {
$options[\PDO::MYSQL_ATTR_SSL_CA] = $this->_data['mysql_ssl_ca_file'];
$options[\PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT] = (bool) $this->_data['mysql_ssl_verify_server_certificate'];
}
$dsn = "mysql:host=" . $this->_data['mysql_host'] . ";"; $dsn = "mysql:host=" . $this->_data['mysql_host'] . ";";
$fatal_fail = false; $fatal_fail = false;
try { try {
@@ -245,15 +255,23 @@ class FroxlorInstall
$content .= $this->_status_message('green', "OK"); $content .= $this->_status_message('green', "OK");
// check for existing db and create backup if so // check for existing db and create backup if so
$content .= $this->_backupExistingDatabase($db_root); $content .= $this->_backupExistingDatabase($db_root);
if (!$this->_abort) {
// create unprivileged user and the database itself // create unprivileged user and the database itself
$content .= $this->_createDatabaseAndUser($db_root); $content .= $this->_createDatabaseAndUser($db_root);
// importing data to new database // importing data to new database
$content .= $this->_importDatabaseData(); $content .= $this->_importDatabaseData();
}
if (! $this->_abort) { if (! $this->_abort) {
// create DB object for new database // create DB object for new database
$options = array( $options = array(
'PDO::MYSQL_ATTR_INIT_COMMAND' => 'SET names utf8' 'PDO::MYSQL_ATTR_INIT_COMMAND' => 'SET names utf8'
); );
if (!empty($this->_data['mysql_ssl_ca_file'])) {
$options[\PDO::MYSQL_ATTR_SSL_CA] = $this->_data['mysql_ssl_ca_file'];
$options[\PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT] = (bool) $this->_data['mysql_ssl_verify_server_certificate'];
}
$dsn = "mysql:host=" . $this->_data['mysql_host'] . ";dbname=" . $this->_data['mysql_database'] . ";"; $dsn = "mysql:host=" . $this->_data['mysql_host'] . ";dbname=" . $this->_data['mysql_database'] . ";";
$another_fail = false; $another_fail = false;
try { try {
@@ -323,10 +341,14 @@ class FroxlorInstall
$userdata .= "\$sql['user']='" . addcslashes($this->_data['mysql_unpriv_user'], "'\\") . "';\n"; $userdata .= "\$sql['user']='" . addcslashes($this->_data['mysql_unpriv_user'], "'\\") . "';\n";
$userdata .= "\$sql['password']='" . addcslashes($this->_data['mysql_unpriv_pass'], "'\\") . "';\n"; $userdata .= "\$sql['password']='" . addcslashes($this->_data['mysql_unpriv_pass'], "'\\") . "';\n";
$userdata .= "\$sql['db']='" . addcslashes($this->_data['mysql_database'], "'\\") . "';\n"; $userdata .= "\$sql['db']='" . addcslashes($this->_data['mysql_database'], "'\\") . "';\n";
$userdata .= "\$sql['ssl']['caFile']='" . addcslashes($this->_data['mysql_ssl_ca_file'], "'\\") . "';\n";
$userdata .= "\$sql['ssl']['verifyServerCertificate']='" . addcslashes($this->_data['mysql_ssl_verify_server_certificate'], "'\\") . "';\n";
$userdata .= "\$sql_root[0]['caption']='Default';\n"; $userdata .= "\$sql_root[0]['caption']='Default';\n";
$userdata .= "\$sql_root[0]['host']='" . addcslashes($this->_data['mysql_host'], "'\\") . "';\n"; $userdata .= "\$sql_root[0]['host']='" . addcslashes($this->_data['mysql_host'], "'\\") . "';\n";
$userdata .= "\$sql_root[0]['user']='" . addcslashes($this->_data['mysql_root_user'], "'\\") . "';\n"; $userdata .= "\$sql_root[0]['user']='" . addcslashes($this->_data['mysql_root_user'], "'\\") . "';\n";
$userdata .= "\$sql_root[0]['password']='" . addcslashes($this->_data['mysql_root_pass'], "'\\") . "';\n"; $userdata .= "\$sql_root[0]['password']='" . addcslashes($this->_data['mysql_root_pass'], "'\\") . "';\n";
$userdata .= "\$sql_root[0]['ssl']['caFile']='" . addcslashes($this->_data['mysql_ssl_ca_file'], "'\\") . "';\n";
$userdata .= "\$sql_root[0]['ssl']['verifyServerCertificate']='" . addcslashes($this->_data['mysql_ssl_verify_server_certificate'], "'\\") . "';\n";
$userdata .= "// enable debugging to browser in case of SQL errors\n"; $userdata .= "// enable debugging to browser in case of SQL errors\n";
$userdata .= "\$sql['debug'] = false;\n"; $userdata .= "\$sql['debug'] = false;\n";
$userdata .= "?>"; $userdata .= "?>";
@@ -359,6 +381,30 @@ class FroxlorInstall
return $content; return $content;
} }
/**
* generate safe unique token
*
* @param int $length
* @return string
*/
private function genUniqueToken(int $length = 16)
{
if(!isset($length) || intval($length) <= 8 ){
$length = 16;
}
if (function_exists('random_bytes')) {
return bin2hex(random_bytes($length));
}
if (function_exists('mcrypt_create_iv')) {
return bin2hex(mcrypt_create_iv($length, MCRYPT_DEV_URANDOM));
}
if (function_exists('openssl_random_pseudo_bytes')) {
return bin2hex(openssl_random_pseudo_bytes($length));
}
// if everything else fails, use unsafe fallback
return md5(uniqid(microtime(), 1));
}
/** /**
* create corresponding entries in froxlor database * create corresponding entries in froxlor database
* *
@@ -403,7 +449,7 @@ class FroxlorInstall
$ins_data = array( $ins_data = array(
'loginname' => $this->_data['admin_user'], 'loginname' => $this->_data['admin_user'],
/* use SHA256 default crypt */ /* use SHA256 default crypt */
'password' => crypt($this->_data['admin_pass1'], '$5$' . md5(uniqid(microtime(), 1)) . md5(uniqid(microtime(), 1))), 'password' => crypt($this->_data['admin_pass1'], '$5$' . $this->genUniqueToken() . $this->genUniqueToken()),
'email' => 'admin@' . $this->_data['servername'], 'email' => 'admin@' . $this->_data['servername'],
'deflang' => $this->_languages[$this->_activelng] 'deflang' => $this->_languages[$this->_activelng]
); );
@@ -504,12 +550,30 @@ class FroxlorInstall
$this->_updateSetting($upd_stmt, 'error', 'system', 'errorlog_level'); $this->_updateSetting($upd_stmt, 'error', 'system', 'errorlog_level');
} }
$distros = glob(\Froxlor\FileDir::makeCorrectDir(\Froxlor\Froxlor::getInstallDir() . '/lib/configfiles/') . '*.xml');
foreach ($distros as $_distribution) {
if ($this->_data['distribution'] == str_replace(".xml", "", strtolower(basename($_distribution)))) {
$dist = new \Froxlor\Config\ConfigParser($_distribution);
$defaults = $dist->getDefaults();
foreach ($defaults->property as $property) {
$this->_updateSetting($upd_stmt, $property->value, $property->settinggroup, $property->varname);
}
}
}
$this->_updateSetting($upd_stmt, $this->_data['activate_newsfeed'], 'admin', 'show_news_feed'); $this->_updateSetting($upd_stmt, $this->_data['activate_newsfeed'], 'admin', 'show_news_feed');
$this->_updateSetting($upd_stmt, dirname(dirname(dirname(__FILE__))), 'system', 'letsencryptchallengepath'); $this->_updateSetting($upd_stmt, dirname(dirname(dirname(__FILE__))), 'system', 'letsencryptchallengepath');
// insert the lastcronrun to be the installation date // insert the lastcronrun to be the installation date
$this->_updateSetting($upd_stmt, time(), 'system', 'lastcronrun'); $this->_updateSetting($upd_stmt, time(), 'system', 'lastcronrun');
// check currently used php version and set values of fpm/fcgid accordingly
if (defined('PHP_MAJOR_VERSION') && defined('PHP_MINOR_VERSION')) {
$reload = "service php" . PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION . "-fpm restart";
$config_dir = "/etc/php/" . PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION . "/fpm/pool.d/";
$db->query("UPDATE `" . TABLE_PANEL_FPMDAEMONS . "` SET `reload_cmd` = '" . $reload . "', `config_dir` = '" . $config_dir . "' WHERE `id` ='1';");
}
// set specific times for some crons (traffic only at night, etc.) // set specific times for some crons (traffic only at night, etc.)
$ts = mktime(0, 0, 0, date('m', time()), date('d', time()), date('Y', time())); $ts = mktime(0, 0, 0, date('m', time()), date('d', time()), date('Y', time()));
$db->query("UPDATE `" . TABLE_PANEL_CRONRUNS . "` SET `lastrun` = '" . $ts . "' WHERE `cronfile` ='cron_traffic';"); $db->query("UPDATE `" . TABLE_PANEL_CRONRUNS . "` SET `lastrun` = '" . $ts . "' WHERE `cronfile` ='cron_traffic';");
@@ -536,6 +600,12 @@ class FroxlorInstall
$options = array( $options = array(
'PDO::MYSQL_ATTR_INIT_COMMAND' => 'SET names utf8' 'PDO::MYSQL_ATTR_INIT_COMMAND' => 'SET names utf8'
); );
if (!empty($this->_data['mysql_ssl_ca_file'])) {
$options[\PDO::MYSQL_ATTR_SSL_CA] = $this->_data['mysql_ssl_ca_file'];
$options[\PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT] = (bool) $this->_data['mysql_ssl_verify_server_certificate'];
}
$dsn = "mysql:host=" . $this->_data['mysql_host'] . ";dbname=" . $this->_data['mysql_database'] . ";"; $dsn = "mysql:host=" . $this->_data['mysql_host'] . ";dbname=" . $this->_data['mysql_database'] . ";";
$fatal_fail = false; $fatal_fail = false;
try { try {
@@ -668,7 +738,7 @@ class FroxlorInstall
if (version_compare($db_root->getAttribute(\PDO::ATTR_SERVER_VERSION), '8.0.11', '>=')) { if (version_compare($db_root->getAttribute(\PDO::ATTR_SERVER_VERSION), '8.0.11', '>=')) {
// create user // create user
$stmt = $db_root->prepare(" $stmt = $db_root->prepare("
CREATE USER '" . $username . "'@'" . $access_host . "' IDENTIFIED BY :password CREATE USER '" . $username . "'@'" . $access_host . "' IDENTIFIED WITH mysql_native_password BY :password
"); ");
$stmt->execute(array( $stmt->execute(array(
"password" => $password "password" => $password
@@ -714,13 +784,18 @@ class FroxlorInstall
)); ));
$rows = $db_root->query("SELECT FOUND_ROWS()")->fetchColumn(); $rows = $db_root->query("SELECT FOUND_ROWS()")->fetchColumn();
$content .= $this->_status_message('begin', $this->_lng['install']['check_db_exists']);
// check result // check result
if ($result_stmt !== false && $rows > 0) { if ($result_stmt !== false && $rows > 0) {
$tables_exist = true; $tables_exist = true;
} }
if ($tables_exist) { if ($tables_exist) {
// tell whats going on if ((int)$this->_data['mysql_forcecreate'] > 0) {
// set status
$content .= $this->_status_message('orange', 'exists (' . $this->_data['mysql_database'] . ')');
// tell what's going on
$content .= $this->_status_message('begin', $this->_lng['install']['backup_old_db']); $content .= $this->_status_message('begin', $this->_lng['install']['backup_old_db']);
// create temporary backup-filename // create temporary backup-filename
@@ -736,16 +811,29 @@ class FroxlorInstall
$mysql_dump = '/usr/local/bin/mysqldump'; $mysql_dump = '/usr/local/bin/mysqldump';
} }
// create temporary .cnf file
$cnffilename = "/tmp/froxlor_dump.cnf";
$dumpcnf = "[mysqldump]" . PHP_EOL . "password=\"" . $this->_data['mysql_root_pass'] . "\"" . PHP_EOL;
file_put_contents($cnffilename, $dumpcnf);
if ($do_backup) { if ($do_backup) {
$command = $mysql_dump . " " . escapeshellarg($this->_data['mysql_database']) . " -u " . escapeshellarg($this->_data['mysql_root_user']) . " --password='" . escapeshellarg($this->_data['mysql_root_pass']) . "' --result-file=" . $filename; $command = $mysql_dump . " --defaults-extra-file=" . $cnffilename . " " . escapeshellarg($this->_data['mysql_database']) . " -u " . escapeshellarg($this->_data['mysql_root_user']) . " --result-file=" . $filename;
$output = exec($command); $output = [];
if (stristr($output, "error")) { exec($command, $output);
@unlink($cnffilename);
if (stristr(implode(" ", $output), "error") || ! file_exists($filename)) {
$content .= $this->_status_message('red', $this->_lng['install']['backup_failed']); $content .= $this->_status_message('red', $this->_lng['install']['backup_failed']);
$this->_abort = true;
} else { } else {
$content .= $this->_status_message('green', 'OK (' . $filename . ')'); $content .= $this->_status_message('green', 'OK (' . $filename . ')');
} }
} else { } else {
$content .= $this->_status_message('red', $this->_lng['install']['backup_binary_missing']); $content .= $this->_status_message('red', $this->_lng['install']['backup_binary_missing']);
$this->_abort = true;
}
} else {
$content .= $this->_status_message('red', $this->_lng['install']['db_exists']);
$this->_abort = true;
} }
} }
@@ -765,7 +853,7 @@ class FroxlorInstall
} }
// language selection // language selection
$language_options = ''; $language_options = '';
foreach ($this->_languages as $language_name => $language_file) { foreach ($this->_languages as $language_file => $language_name) {
$language_options .= \Froxlor\UI\HTML::makeoption($language_name, $language_file, $this->_activelng, true, true); $language_options .= \Froxlor\UI\HTML::makeoption($language_name, $language_file, $this->_activelng, true, true);
} }
// get language-form-template // get language-form-template
@@ -782,6 +870,8 @@ class FroxlorInstall
$formdata .= $this->_getSectionItemString('mysql_host', true); $formdata .= $this->_getSectionItemString('mysql_host', true);
// database // database
$formdata .= $this->_getSectionItemString('mysql_database', true); $formdata .= $this->_getSectionItemString('mysql_database', true);
// database overwrite if exists?
$formdata .= $this->_getSectionItemYesNo('mysql_forcecreate', false);
// unpriv-user has to be different from root // unpriv-user has to be different from root
if ($this->_data['mysql_unpriv_user'] == $this->_data['mysql_root_user']) { if ($this->_data['mysql_unpriv_user'] == $this->_data['mysql_root_user']) {
$style = 'blue'; $style = 'blue';
@@ -811,6 +901,9 @@ class FroxlorInstall
} }
$formdata .= $this->_getSectionItemString('mysql_root_pass', true, $style, 'password'); $formdata .= $this->_getSectionItemString('mysql_root_pass', true, $style, 'password');
$formdata .= $this->_getSectionItemString('mysql_ssl_ca_file', false, $style);
$formdata .= $this->_getSectionItemYesNo('mysql_ssl_verify_server_certificate', false, $style);
/** /**
* admin data * admin data
*/ */
@@ -840,6 +933,37 @@ class FroxlorInstall
*/ */
$section = $this->_lng['install']['serversettings']; $section = $this->_lng['install']['serversettings'];
eval("\$formdata .= \"" . $this->_getTemplate("datasection") . "\";"); eval("\$formdata .= \"" . $this->_getTemplate("datasection") . "\";");
// distribution
if (! empty($_POST['installstep']) && $this->_data['distribution'] == '') {
$diststyle = 'color:red;';
} else {
$diststyle = '';
}
// show list of available distro's
$distributions_select_data = [];
$distros = glob(\Froxlor\FileDir::makeCorrectDir(\Froxlor\Froxlor::getInstallDir() . '/lib/configfiles/') . '*.xml');
foreach ($distros as $_distribution) {
$dist = new \Froxlor\Config\ConfigParser($_distribution);
$dist_display = $dist->distributionName . " " . $dist->distributionCodename . " (" . $dist->distributionVersion . ")";
if (!array_key_exists($dist_display, $distributions_select_data)) {
$distributions_select_data[$dist_display] = '';
}
$distributions_select_data[$dist_display] .= str_replace(".xml", "", strtolower(basename($_distribution)));
}
// sort by distribution name
ksort($distributions_select_data);
$distributions_select = '';
foreach ($distributions_select_data as $dist_display => $dist_index) {
// create select-box-option
$distributions_select .= \Froxlor\UI\HTML::makeoption($dist_display, $dist_index, $this->_data['distribution'] ?? '');
// $this->_data['distribution']
}
$formdata .= $this->_getSectionItemSelectbox('distribution', $distributions_select, $diststyle);
// servername // servername
if (! empty($_POST['installstep']) && $this->_data['servername'] == '') { if (! empty($_POST['installstep']) && $this->_data['servername'] == '') {
$style = 'color:red;'; $style = 'color:red;';
@@ -861,12 +985,12 @@ class FroxlorInstall
$websrvstyle = ''; $websrvstyle = '';
} }
// apache // apache
$formdata .= $this->_getSectionItemCheckbox('apache2', ($this->_data['webserver'] == 'apache2'), $websrvstyle); $formdata .= $this->_getSectionItemCheckbox('webserver', 'apache2', ($this->_data['webserver'] == 'apache2'), $websrvstyle);
$formdata .= $this->_getSectionItemCheckbox('apache24', ($this->_data['webserver'] == 'apache24'), $websrvstyle); $formdata .= $this->_getSectionItemCheckbox('webserver', 'apache24', ($this->_data['webserver'] == 'apache24'), $websrvstyle);
// lighttpd // lighttpd
$formdata .= $this->_getSectionItemCheckbox('lighttpd', ($this->_data['webserver'] == 'lighttpd'), $websrvstyle); $formdata .= $this->_getSectionItemCheckbox('webserver', 'lighttpd', ($this->_data['webserver'] == 'lighttpd'), $websrvstyle);
// nginx // nginx
$formdata .= $this->_getSectionItemCheckbox('nginx', ($this->_data['webserver'] == 'nginx'), $websrvstyle); $formdata .= $this->_getSectionItemCheckbox('webserver', 'nginx', ($this->_data['webserver'] == 'nginx'), $websrvstyle);
// webserver-user // webserver-user
if (! empty($_POST['installstep']) && $this->_data['httpuser'] == '') { if (! empty($_POST['installstep']) && $this->_data['httpuser'] == '') {
$style = 'color:red;'; $style = 'color:red;';
@@ -918,7 +1042,7 @@ class FroxlorInstall
} }
/** /**
* generate form radio field for webserver-selection * generate form radio field
* *
* @param string $fieldname * @param string $fieldname
* @param boolean $checked * @param boolean $checked
@@ -926,8 +1050,9 @@ class FroxlorInstall
* *
* @return string * @return string
*/ */
private function _getSectionItemCheckbox($fieldname = null, $checked = false, $style = "") private function _getSectionItemCheckbox($groupname = null, $fieldname = null, $checked = false, $style = "")
{ {
$groupname = $this->_lng['install'][$groupname];
$fieldlabel = $this->_lng['install'][$fieldname]; $fieldlabel = $this->_lng['install'][$fieldname];
if ($checked) { if ($checked) {
$checked = 'checked="checked"'; $checked = 'checked="checked"';
@@ -937,6 +1062,24 @@ class FroxlorInstall
return $sectionitem; return $sectionitem;
} }
/**
* generate form selectbox
*
* @param string $fieldname
* @param boolean $options
* @param string $style
*
* @return string
*/
private function _getSectionItemSelectbox($fieldname = null, $options = null, $style = "")
{
$fieldlabel = $this->_lng['install'][$fieldname];
$sectionitem = "";
eval("\$sectionitem .= \"" . $this->_getTemplate("dataitemselect") . "\";");
return $sectionitem;
}
/** /**
* generate form checkbox field * generate form checkbox field
* *
@@ -971,11 +1114,11 @@ class FroxlorInstall
// check for correct php version // check for correct php version
$content .= $this->_status_message('begin', $this->_lng['requirements']['phpversion']); $content .= $this->_status_message('begin', $this->_lng['requirements']['phpversion']);
if (version_compare("7.0.0", PHP_VERSION, ">=")) { if (version_compare("7.1.0", PHP_VERSION, ">=")) {
$content .= $this->_status_message('red', $this->_lng['requirements']['notfound'] . ' (' . PHP_VERSION . ')'); $content .= $this->_status_message('red', $this->_lng['requirements']['notfound'] . ' (' . PHP_VERSION . ')');
$_die = true; $_die = true;
} else { } else {
if (version_compare("7.1.0", PHP_VERSION, ">=")) { if (version_compare("7.4.0", PHP_VERSION, ">=")) {
$content .= $this->_status_message('orange', $this->_lng['requirements']['newerphpprefered'] . ' (' . PHP_VERSION . ')'); $content .= $this->_status_message('orange', $this->_lng['requirements']['newerphpprefered'] . ' (' . PHP_VERSION . ')');
} else { } else {
$content .= $this->_status_message('green', PHP_VERSION); $content .= $this->_status_message('green', PHP_VERSION);
@@ -1241,10 +1384,12 @@ class FroxlorInstall
// from form // from form
if (! empty($_POST['serverip'])) { if (! empty($_POST['serverip'])) {
$this->_data['serverip'] = $_POST['serverip']; $this->_data['serverip'] = $_POST['serverip'];
$this->_data['serverip'] = inet_ntop(inet_pton($this->_data['serverip']));
return; return;
// from $_SERVER // from $_SERVER
} elseif (! empty($_SERVER['SERVER_ADDR'])) { } elseif (! empty($_SERVER['SERVER_ADDR'])) {
$this->_data['serverip'] = $_SERVER['SERVER_ADDR']; $this->_data['serverip'] = $_SERVER['SERVER_ADDR'];
$this->_data['serverip'] = inet_ntop(inet_pton($this->_data['serverip']));
return; return;
} }
// empty // empty
@@ -1273,6 +1418,49 @@ class FroxlorInstall
} }
} }
/**
* get/guess linux distribution
*/
private function _guessDistribution()
{
// post
if (! empty($_POST['distribution'])) {
$this->_data['distribution'] = $_POST['distribution'];
} else {
// set default os.
$os_dist = array(
'ID' => 'buster'
);
$os_version = array(
'0' => '10'
);
// read os-release
if (file_exists('/etc/os-release')) {
$os_dist_content = file_get_contents('/etc/os-release');
$os_dist_arr = explode("\n", $os_dist_content);
$os_dist = [];
foreach ($os_dist_arr as $os_dist_line) {
if (empty(trim($os_dist_line))) continue;
$tmp = explode("=", $os_dist_line);
$os_dist[$tmp[0]] = str_replace('"', "", trim($tmp[1]));
}
if (is_array($os_dist) && array_key_exists('ID', $os_dist) && array_key_exists('VERSION_ID', $os_dist)) {
$os_version = explode('.', $os_dist['VERSION_ID'])[0];
}
}
$distros = glob(\Froxlor\FileDir::makeCorrectDir(\Froxlor\Froxlor::getInstallDir() . '/lib/configfiles/') . '*.xml');
foreach ($distros as $_distribution) {
$dist = new \Froxlor\Config\ConfigParser($_distribution);
$ver = explode('.', $dist->distributionVersion)[0];
if (strtolower($os_dist['ID']) == strtolower($dist->distributionName) && $os_version == $ver) {
$this->_data['distribution'] = str_replace(".xml", "", strtolower(basename($_distribution)));
}
}
}
}
/** /**
* check if POST field is set and get value for the * check if POST field is set and get value for the
* internal data array, if not set use either '' or $default if != null * internal data array, if not set use either '' or $default if != null

View File

@@ -30,6 +30,7 @@
*/ */
function showUpdateStep($task = null, $needs_status = true) function showUpdateStep($task = null, $needs_status = true)
{ {
set_time_limit(30);
if (! $needs_status) if (! $needs_status)
echo "<b>"; echo "<b>";
@@ -41,7 +42,6 @@ function showUpdateStep($task = null, $needs_status = true)
} }
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, $task); \Froxlor\FroxlorLogger::getInstanceOf()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, $task);
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, $task);
} }
/** /**
@@ -82,7 +82,6 @@ function lastStepStatus($status = -1, $message = '')
if ($status == - 1 || $status == 2) { if ($status == - 1 || $status == 2) {
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, 'Attention - last update task failed!!!'); \Froxlor\FroxlorLogger::getInstanceOf()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, 'Attention - last update task failed!!!');
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, 'Attention - last update task failed!!!');
} elseif ($status == 0 || $status == 1) { } elseif ($status == 0 || $status == 1) {
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, 'Success'); \Froxlor\FroxlorLogger::getInstanceOf()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, 'Success');
} }

View File

@@ -23,7 +23,7 @@ $lng['requirements']['notfound'] = 'not found';
$lng['requirements']['notinstalled'] = 'not installed'; $lng['requirements']['notinstalled'] = 'not installed';
$lng['requirements']['activated'] = 'enabled'; $lng['requirements']['activated'] = 'enabled';
$lng['requirements']['phpversion'] = 'PHP version >= 7.0'; $lng['requirements']['phpversion'] = 'PHP version >= 7.0';
$lng['requirements']['newerphpprefered'] = 'Good, but php-7.1 is prefered.'; $lng['requirements']['newerphpprefered'] = 'Good, but php-7.1 is preferred.';
$lng['requirements']['phppdo'] = 'PHP PDO extension and PDO-MySQL driver...'; $lng['requirements']['phppdo'] = 'PHP PDO extension and PDO-MySQL driver...';
$lng['requirements']['phpsession'] = 'PHP session-extension...'; $lng['requirements']['phpsession'] = 'PHP session-extension...';
$lng['requirements']['phpctype'] = 'PHP ctype-extension...'; $lng['requirements']['phpctype'] = 'PHP ctype-extension...';
@@ -39,7 +39,7 @@ $lng['requirements']['phpjson'] = 'PHP json-extension...';
$lng['requirements']['bcmathdescription'] = 'Traffic-calculation related functions will not work correctly!'; $lng['requirements']['bcmathdescription'] = 'Traffic-calculation related functions will not work correctly!';
$lng['requirements']['zipdescription'] = 'The auto-update feature requires the zip extension.'; $lng['requirements']['zipdescription'] = 'The auto-update feature requires the zip extension.';
$lng['requirements']['openbasedir'] = 'open_basedir...'; $lng['requirements']['openbasedir'] = 'open_basedir...';
$lng['requirements']['openbasedirenabled'] = 'Froxlor will not work properly with open_basedir enabled. Please disable open_basedir for Froxlor in the coresponding php.ini'; $lng['requirements']['openbasedirenabled'] = 'Froxlor will not work properly with open_basedir enabled. Please disable open_basedir for Froxlor in the corresponding php.ini';
$lng['requirements']['mysqldump'] = 'MySQL dump tool'; $lng['requirements']['mysqldump'] = 'MySQL dump tool';
$lng['requirements']['mysqldumpmissing'] = 'Automatic backup of possible existing database is not possible. Please install mysql-client tools'; $lng['requirements']['mysqldumpmissing'] = 'Automatic backup of possible existing database is not possible. Please install mysql-client tools';
$lng['requirements']['diedbecauseofrequirements'] = 'Cannot install Froxlor without these requirements! Try to fix them and retry.'; $lng['requirements']['diedbecauseofrequirements'] = 'Cannot install Froxlor without these requirements! Try to fix them and retry.';
@@ -53,16 +53,20 @@ $lng['install']['welcometext'] = 'Thank you for choosing Froxlor. Please fill ou
$lng['install']['database'] = 'Database connection'; $lng['install']['database'] = 'Database connection';
$lng['install']['mysql_host'] = 'MySQL-Hostname'; $lng['install']['mysql_host'] = 'MySQL-Hostname';
$lng['install']['mysql_database'] = 'Database name'; $lng['install']['mysql_database'] = 'Database name';
$lng['install']['mysql_forcecreate'] = 'Backup and overwrite database if exists?';
$lng['install']['mysql_unpriv_user'] = 'Username for the unprivileged MySQL-account'; $lng['install']['mysql_unpriv_user'] = 'Username for the unprivileged MySQL-account';
$lng['install']['mysql_unpriv_pass'] = 'Password for the unprivileged MySQL-account'; $lng['install']['mysql_unpriv_pass'] = 'Password for the unprivileged MySQL-account';
$lng['install']['mysql_root_user'] = 'Username for the MySQL-root-account'; $lng['install']['mysql_root_user'] = 'Username for the MySQL-root-account';
$lng['install']['mysql_root_pass'] = 'Password for the MySQL-root-account'; $lng['install']['mysql_root_pass'] = 'Password for the MySQL-root-account';
$lng['install']['mysql_ssl_ca_file'] = 'MySQL server certificate file path';
$lng['install']['mysql_ssl_verify_server_certificate'] = 'Verify MySQL TLS certificate';
$lng['install']['admin_account'] = 'Administrator Account'; $lng['install']['admin_account'] = 'Administrator Account';
$lng['install']['admin_user'] = 'Administrator Username'; $lng['install']['admin_user'] = 'Administrator Username';
$lng['install']['admin_pass1'] = 'Administrator Password'; $lng['install']['admin_pass1'] = 'Administrator Password';
$lng['install']['admin_pass2'] = 'Administrator-Password (confirm)'; $lng['install']['admin_pass2'] = 'Administrator-Password (confirm)';
$lng['install']['activate_newsfeed'] = 'Enable the official newsfeed<br><small>(https://inside.froxlor.org/news/)</small>'; $lng['install']['activate_newsfeed'] = 'Enable the official newsfeed<br><small>(https://inside.froxlor.org/news/)</small>';
$lng['install']['serversettings'] = 'Server settings'; $lng['install']['serversettings'] = 'Server settings';
$lng['install']['distribution'] = 'Distribution';
$lng['install']['servername'] = 'Server name (FQDN, no ip-address)'; $lng['install']['servername'] = 'Server name (FQDN, no ip-address)';
$lng['install']['serverip'] = 'Server IP'; $lng['install']['serverip'] = 'Server IP';
$lng['install']['webserver'] = 'Webserver'; $lng['install']['webserver'] = 'Webserver';
@@ -78,6 +82,8 @@ $lng['install']['testing_mysql_fail'] = 'There seems to be a problem with the da
$lng['install']['backup_old_db'] = 'Creating backup of old database...'; $lng['install']['backup_old_db'] = 'Creating backup of old database...';
$lng['install']['backup_binary_missing'] = 'Could not find mysqldump'; $lng['install']['backup_binary_missing'] = 'Could not find mysqldump';
$lng['install']['backup_failed'] = 'Could not backup database'; $lng['install']['backup_failed'] = 'Could not backup database';
$lng['install']['check_db_exists'] = 'Checking database...';
$lng['install']['db_exists'] = 'Unable to create database. A database with the same name exists and should not be overwritten';
$lng['install']['prepare_db'] = 'Preparing database...'; $lng['install']['prepare_db'] = 'Preparing database...';
$lng['install']['create_mysqluser_and_db'] = 'Creating database and username...'; $lng['install']['create_mysqluser_and_db'] = 'Creating database and username...';
$lng['install']['testing_new_db'] = 'Testing if database and user have been created correctly...'; $lng['install']['testing_new_db'] = 'Testing if database and user have been created correctly...';

View File

@@ -53,6 +53,7 @@ $lng['install']['admin_user'] = 'Nom d\'utilisateur administrateur';
$lng['install']['admin_pass1'] = 'Mot de passe administrateur'; $lng['install']['admin_pass1'] = 'Mot de passe administrateur';
$lng['install']['admin_pass2'] = 'Mot de passe administrateur (confirmez)'; $lng['install']['admin_pass2'] = 'Mot de passe administrateur (confirmez)';
$lng['install']['serversettings'] = 'Réglages serveur'; $lng['install']['serversettings'] = 'Réglages serveur';
$lng['install']['distribution'] = 'Distribution';
$lng['install']['servername'] = 'Nom du serveur (FQDN, pas d\'adresse IP)'; $lng['install']['servername'] = 'Nom du serveur (FQDN, pas d\'adresse IP)';
$lng['install']['serverip'] = 'Adresse IP du serveur'; $lng['install']['serverip'] = 'Adresse IP du serveur';
$lng['install']['webserver'] = 'Serveur Web'; $lng['install']['webserver'] = 'Serveur Web';

View File

@@ -53,16 +53,20 @@ $lng['install']['welcometext'] = 'Vielen Dank dass Sie sich für Froxlor entschi
$lng['install']['database'] = 'Datenbankverbindung'; $lng['install']['database'] = 'Datenbankverbindung';
$lng['install']['mysql_host'] = 'MySQL-Hostname'; $lng['install']['mysql_host'] = 'MySQL-Hostname';
$lng['install']['mysql_database'] = 'Datenbank Name'; $lng['install']['mysql_database'] = 'Datenbank Name';
$lng['install']['mysql_forcecreate'] = 'Datenbank sichern und überschreiben wenn vorhanden?';
$lng['install']['mysql_unpriv_user'] = 'Benutzername für den unprivilegierten MySQL-Account'; $lng['install']['mysql_unpriv_user'] = 'Benutzername für den unprivilegierten MySQL-Account';
$lng['install']['mysql_unpriv_pass'] = 'Passwort für den unprivilegierten MySQL-Account'; $lng['install']['mysql_unpriv_pass'] = 'Passwort für den unprivilegierten MySQL-Account';
$lng['install']['mysql_root_user'] = 'Benutzername für den MySQL-Root-Account'; $lng['install']['mysql_root_user'] = 'Benutzername für den MySQL-Root-Account';
$lng['install']['mysql_root_pass'] = 'Passwort für den MySQL-Root-Account'; $lng['install']['mysql_root_pass'] = 'Passwort für den MySQL-Root-Account';
$lng['install']['mysql_ssl_ca_file'] = 'MySQL-Server Zertifikatspfad';
$lng['install']['mysql_ssl_verify_server_certificate'] = 'Validieren des MySQL-Server Zertifikats';
$lng['install']['admin_account'] = 'Admin-Zugang'; $lng['install']['admin_account'] = 'Admin-Zugang';
$lng['install']['admin_user'] = 'Administrator-Benutzername'; $lng['install']['admin_user'] = 'Administrator-Benutzername';
$lng['install']['admin_pass1'] = 'Administrator-Passwort'; $lng['install']['admin_pass1'] = 'Administrator-Passwort';
$lng['install']['admin_pass2'] = 'Administrator-Passwort (Bestätigung)'; $lng['install']['admin_pass2'] = 'Administrator-Passwort (Bestätigung)';
$lng['install']['activate_newsfeed'] = 'Aktiviere das offizielle Newsfeed<br><small>(https://inside.froxlor.org/news/)</small>'; $lng['install']['activate_newsfeed'] = 'Aktiviere das offizielle Newsfeed<br><small>(https://inside.froxlor.org/news/)</small>';
$lng['install']['serversettings'] = 'Servereinstellungen'; $lng['install']['serversettings'] = 'Servereinstellungen';
$lng['install']['distribution'] = 'Distribution';
$lng['install']['servername'] = 'Servername (FQDN, keine IP-Adresse)'; $lng['install']['servername'] = 'Servername (FQDN, keine IP-Adresse)';
$lng['install']['serverip'] = 'Server-IP'; $lng['install']['serverip'] = 'Server-IP';
$lng['install']['webserver'] = 'Webserver'; $lng['install']['webserver'] = 'Webserver';
@@ -78,6 +82,8 @@ $lng['install']['testing_mysql_fail'] = 'Bei der Verwendung der Datenbank gibt e
$lng['install']['backup_old_db'] = 'Sicherung vorheriger Datenbank...'; $lng['install']['backup_old_db'] = 'Sicherung vorheriger Datenbank...';
$lng['install']['backup_binary_missing'] = 'Konnte mysqldump nicht finden'; $lng['install']['backup_binary_missing'] = 'Konnte mysqldump nicht finden';
$lng['install']['backup_failed'] = 'Sicherung fehlgeschlagen'; $lng['install']['backup_failed'] = 'Sicherung fehlgeschlagen';
$lng['install']['check_db_exists'] = 'Databenbank wird geprüft...';
$lng['install']['db_exists'] = 'Datenbank kann nicht erstellt werden. Eine Datenbank mit dem selben Namen existiert bereits und soll nicht überschrieben werden.';
$lng['install']['prepare_db'] = 'Datenbank wird vorbereitet...'; $lng['install']['prepare_db'] = 'Datenbank wird vorbereitet...';
$lng['install']['create_mysqluser_and_db'] = 'Erstelle Datenbank und Benutzer...'; $lng['install']['create_mysqluser_and_db'] = 'Erstelle Datenbank und Benutzer...';
$lng['install']['testing_new_db'] = 'Teste, ob Datenbank und Benutzer korrekt angelegt wurden...'; $lng['install']['testing_new_db'] = 'Teste, ob Datenbank und Benutzer korrekt angelegt wurden...';

View File

@@ -1,4 +1,4 @@
<p> <p>
<label for="{$fieldname}" class="install-block {$style}">{$this->_lng['install']['webserver']} {$fieldlabel}:</label> <label for="{$fieldname}" class="install-block {$style}">{$groupname} {$fieldlabel}:</label>
<input type="radio" name="webserver" id="{$fieldname}" value="{$fieldname}" {$checked} /><span>{$fieldlabel}</span> <input type="radio" name="{$groupname}" id="{$fieldname}" value="{$fieldname}" {$checked} /><span>{$fieldlabel}</span>
</p> </p>

View File

@@ -0,0 +1,6 @@
<p>
<label for="{$fieldname}" class="install-block {$style}">{$fieldlabel}:</label>
<select name="{$fieldname}" id="{$fieldname}" class="dropdown">
{$options}
</select>
</p>

View File

@@ -1,6 +1,7 @@
<?php <?php
use Froxlor\Database\Database; use Froxlor\Database\Database;
use Froxlor\Settings; use Froxlor\Settings;
use Froxlor\Validate\Validate;
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
@@ -624,8 +625,9 @@ if (\Froxlor\Froxlor::isDatabaseVersion('202004140')) {
// check for duplicate entries prior to set a unique key to avoid errors on update // check for duplicate entries prior to set a unique key to avoid errors on update
Database::query(" Database::query("
DELETE a.* FROM domain_ssl_settings AS a DELETE a.* FROM domain_ssl_settings AS a
LEFT JOIN domain_ssl_settings AS b ON UNIX_TIMESTAMP(b.`expirationdate`) > UNIX_TIMESTAMP(a.`expirationdate`) LEFT JOIN domain_ssl_settings AS b ON
AND (b.`domainid`=a.`domainid` OR (UNIX_TIMESTAMP(b.`expirationdate`) = UNIX_TIMESTAMP(a.`expirationdate`) AND b.`id`>a.`id`)) ((b.`domainid`=a.`domainid` AND UNIX_TIMESTAMP(b.`expirationdate`) > UNIX_TIMESTAMP(a.`expirationdate`))
OR (UNIX_TIMESTAMP(b.`expirationdate`) = UNIX_TIMESTAMP(a.`expirationdate`) AND b.`id`>a.`id`))
WHERE b.`id` IS NOT NULL WHERE b.`id` IS NOT NULL
"); ");
Database::query("ALTER TABLE `domain_ssl_settings` ADD UNIQUE(`domainid`)"); Database::query("ALTER TABLE `domain_ssl_settings` ADD UNIQUE(`domainid`)");
@@ -638,3 +640,306 @@ if (\Froxlor\Froxlor::isFroxlorVersion('0.10.16')) {
showUpdateStep("Updating from 0.10.16 to 0.10.17", false); showUpdateStep("Updating from 0.10.16 to 0.10.17", false);
\Froxlor\Froxlor::updateToVersion('0.10.17'); \Froxlor\Froxlor::updateToVersion('0.10.17');
} }
if (\Froxlor\Froxlor::isFroxlorVersion('0.10.17')) {
showUpdateStep("Updating from 0.10.17 to 0.10.18", false);
\Froxlor\Froxlor::updateToVersion('0.10.18');
}
if (\Froxlor\Froxlor::isFroxlorVersion('0.10.18')) {
showUpdateStep("Updating from 0.10.18 to 0.10.19", false);
\Froxlor\Froxlor::updateToVersion('0.10.19');
}
if (\Froxlor\Froxlor::isDatabaseVersion('202005150')) {
showUpdateStep("Add new performance indexes", true);
Database::query("ALTER TABLE panel_customers ADD INDEX guid (guid);");
Database::query("ALTER TABLE panel_tasks ADD INDEX type (type);");
Database::query("ALTER TABLE mail_users ADD INDEX username (username);");
Database::query("ALTER TABLE mail_users ADD INDEX imap (imap);");
Database::query("ALTER TABLE mail_users ADD INDEX pop3 (pop3);");
Database::query("ALTER TABLE ftp_groups ADD INDEX gid (gid);");
lastStepStatus(0);
\Froxlor\Froxlor::updateToDbVersion('202007240');
}
if (\Froxlor\Froxlor::isFroxlorVersion('0.10.19')) {
showUpdateStep("Updating from 0.10.19 to 0.10.20", false);
\Froxlor\Froxlor::updateToVersion('0.10.20');
}
if (\Froxlor\Froxlor::isDatabaseVersion('202007240')) {
showUpdateStep("Removing old unused table", true);
Database::query("DROP TABLE IF EXISTS `panel_diskspace_admins`;");
lastStepStatus(0);
\Froxlor\Froxlor::updateToDbVersion('202009070');
}
if (\Froxlor\Froxlor::isFroxlorVersion('0.10.20')) {
showUpdateStep("Updating from 0.10.20 to 0.10.21", false);
\Froxlor\Froxlor::updateToVersion('0.10.21');
}
if (\Froxlor\Froxlor::isFroxlorVersion('0.10.21')) {
showUpdateStep("Adding settings for ssl-vhost default content if not updated from db-version 201910110", true);
Settings::AddNew("system.default_sslvhostconf", '');
lastStepStatus(0);
showUpdateStep("Updating from 0.10.21 to 0.10.22", false);
\Froxlor\Froxlor::updateToVersion('0.10.22');
}
if (\Froxlor\Froxlor::isFroxlorVersion('0.10.22')) {
showUpdateStep("Updating from 0.10.22 to 0.10.23", false);
\Froxlor\Froxlor::updateToVersion('0.10.23');
}
if (\Froxlor\Froxlor::isFroxlorVersion('0.10.23')) {
showUpdateStep("Updating from 0.10.23 to 0.10.23.1", false);
\Froxlor\Froxlor::updateToVersion('0.10.23.1');
}
if (\Froxlor\Froxlor::isDatabaseVersion('202009070')) {
showUpdateStep("Adding setting to hide incompatible settings", true);
Settings::AddNew("system.hide_incompatible_settings", '0');
lastStepStatus(0);
\Froxlor\Froxlor::updateToDbVersion('202012300');
}
if (\Froxlor\Froxlor::isDatabaseVersion('202012300')) {
showUpdateStep("Adding setting for DKIM private key extension/suffix", true);
Settings::AddNew("dkim.privkeysuffix", '.priv');
lastStepStatus(0);
\Froxlor\Froxlor::updateToDbVersion('202101200');
}
if (\Froxlor\Froxlor::isFroxlorVersion('0.10.23.1')) {
showUpdateStep("Updating from 0.10.23.1 to 0.10.24", false);
\Froxlor\Froxlor::updateToVersion('0.10.24');
}
if (\Froxlor\Froxlor::isDatabaseVersion('202101200')) {
showUpdateStep("Adding setting for mail address used in SOA records", true);
Settings::AddNew("system.soaemail", '');
lastStepStatus(0);
\Froxlor\Froxlor::updateToDbVersion('202102200');
}
/*
* skip due to potential "1118 Row size too large" error
*
if (\Froxlor\Froxlor::isDatabaseVersion('202102200')) {
showUpdateStep("Add new description fields to mail and domain table", true);
Database::query("ALTER TABLE panel_domains ADD `description` varchar(255) NOT NULL DEFAULT '' AFTER `ssl_sessiontickets`;");
Database::query("ALTER TABLE mail_virtual ADD `description` varchar(255) NOT NULL DEFAULT '' AFTER `iscatchall`");
lastStepStatus(0);
\Froxlor\Froxlor::updateToDbVersion('202103030');
}
*/
if (\Froxlor\Froxlor::isFroxlorVersion('0.10.24')) {
showUpdateStep("Updating from 0.10.24 to 0.10.25", false);
\Froxlor\Froxlor::updateToVersion('0.10.25');
}
if (\Froxlor\Froxlor::isDatabaseVersion('202102200') || \Froxlor\Froxlor::isDatabaseVersion('202103030')) {
showUpdateStep("Refactoring columns from large tables", true);
Database::query("ALTER TABLE panel_domains CHANGE `ssl_protocols` `ssl_protocols` varchar(255) NOT NULL DEFAULT '';");
Database::query("ALTER TABLE panel_domains CHANGE `ssl_cipher_list` `ssl_cipher_list` varchar(500) NOT NULL DEFAULT '';");
Database::query("ALTER TABLE panel_domains CHANGE `tlsv13_cipher_list` `tlsv13_cipher_list` varchar(500) NOT NULL DEFAULT '';");
lastStepStatus(0);
showUpdateStep("Add new description fields to mail and domain table", true);
$result = Database::query("DESCRIBE `panel_domains`");
$columnfound = 0;
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
if ($row['Field'] == 'description') {
$columnfound = 1;
}
}
if (! $columnfound) {
Database::query("ALTER TABLE panel_domains ADD `description` varchar(255) NOT NULL DEFAULT '' AFTER `ssl_sessiontickets`;");
}
$result = Database::query("DESCRIBE `mail_virtual`");
$columnfound = 0;
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
if ($row['Field'] == 'description') {
$columnfound = 1;
}
}
if (! $columnfound) {
Database::query("ALTER TABLE mail_virtual ADD `description` varchar(255) NOT NULL DEFAULT '' AFTER `iscatchall`");
}
lastStepStatus(0);
\Froxlor\Froxlor::updateToDbVersion('202103110');
}
if (\Froxlor\Froxlor::isDatabaseVersion('202103110')) {
showUpdateStep("Adding settings for imprint, terms of use and privacy policy URLs", true);
Settings::AddNew("panel.imprint_url", '');
Settings::AddNew("panel.terms_url", '');
Settings::AddNew("panel.privacy_url", '');
lastStepStatus(0);
\Froxlor\Froxlor::updateToDbVersion('202103240');
}
if (\Froxlor\Froxlor::isFroxlorVersion('0.10.25')) {
showUpdateStep("Updating from 0.10.25 to 0.10.26", false);
\Froxlor\Froxlor::updateToVersion('0.10.26');
}
if (\Froxlor\Froxlor::isDatabaseVersion('202103240')) {
showUpdateStep("Adding setting for default serveralias value for new domains", true);
Settings::AddNew("system.domaindefaultalias", '0');
lastStepStatus(0);
\Froxlor\Froxlor::updateToDbVersion('202106160');
}
if (\Froxlor\Froxlor::isDatabaseVersion('202106160')) {
showUpdateStep("Adjusting Let's Encrypt endpoint configuration to support ZeroSSL", true);
if (Settings::Get('system.letsencryptca') == 'testing') {
Settings::Set("system.letsencryptca", 'letsencrypt_test');
} else {
Settings::Set("system.letsencryptca", 'letsencrypt');
}
lastStepStatus(0);
\Froxlor\Froxlor::updateToDbVersion('202106270');
}
if (\Froxlor\Froxlor::isDatabaseVersion('202106270')) {
showUpdateStep("Adding custom logo image settings", true);
Settings::AddNew("panel.logo_image_header", '');
Settings::AddNew("panel.logo_image_login", '');
lastStepStatus(0);
// Migrating old custom logo over, if exists
$custom_logo_file_old = \Froxlor\Froxlor::getInstallDir() . '/templates/Sparkle/assets/img/logo_custom.png';
if (file_exists($custom_logo_file_old)) {
showUpdateStep("Migrating existing custom logo to new settings", true);
$path = \Froxlor\Froxlor::getInstallDir().'/img/';
if (!is_dir($path) && !mkdir($path, 0775)) {
throw new \Exception("img directory does not exist and cannot be created");
}
if (!is_writable($path)) {
if (!chmod($path, '0775')) {
throw new \Exception("Cannot write to img directory");
}
}
// Save as new custom logo header
$save_to = 'logo_header.png';
copy($custom_logo_file_old, $path.$save_to);
Settings::Set("panel.logo_image_header", "img/{$save_to}?v=".time());
// Save as new custom logo login
$save_to = 'logo_login.png';
copy($custom_logo_file_old, $path.$save_to);
Settings::Set("panel.logo_image_login", "img/{$save_to}?v=".time());
lastStepStatus(0);
}
\Froxlor\Froxlor::updateToDbVersion('202107070');
}
if (\Froxlor\Froxlor::isFroxlorVersion('0.10.26')) {
showUpdateStep("Updating from 0.10.26 to 0.10.27", false);
\Froxlor\Froxlor::updateToVersion('0.10.27');
}
if (\Froxlor\Froxlor::isDatabaseVersion('202107070')) {
showUpdateStep("Adding settings to overwrite theme- or custom theme-logo with the new logo settings", true);
Settings::AddNew("panel.logo_overridetheme", '0');
Settings::AddNew("panel.logo_overridecustom", '0');
lastStepStatus(0);
\Froxlor\Froxlor::updateToDbVersion('202107200');
}
if (\Froxlor\Froxlor::isDatabaseVersion('202107200')) {
showUpdateStep("Adding settings to define default value of 'create std-subdomain' when creating a customer", true);
Settings::AddNew("system.createstdsubdom_default", '1');
lastStepStatus(0);
\Froxlor\Froxlor::updateToDbVersion('202107210');
}
if (\Froxlor\Froxlor::isDatabaseVersion('202107210')) {
showUpdateStep("Normalizing ipv6 for correct comparison", true);
$result_stmt = Database::prepare("
SELECT `id`, `ip` FROM `" . TABLE_PANEL_IPSANDPORTS . "`"
);
Database::pexecute($result_stmt);
$upd_stmt = Database::prepare("UPDATE `" . TABLE_PANEL_IPSANDPORTS . "` SET `ip` = :ip WHERE `id` = :id");
while ($iprow = $result_stmt->fetch(\PDO::FETCH_ASSOC)) {
if (Validate::is_ipv6($iprow['ip'])) {
$ip = inet_ntop(inet_pton($iprow['ip']));
Database::pexecute($upd_stmt, [
'ip' => $ip,
'id' => $iprow['id']
]);
}
}
lastStepStatus(0);
\Froxlor\Froxlor::updateToDbVersion('202107260');
}
if (\Froxlor\Froxlor::isDatabaseVersion('202107260')) {
showUpdateStep("Removing setting for search-engine allow yes/no", true);
Database::query("DELETE FROM `" . TABLE_PANEL_SETTINGS . "` WHERE `settinggroup` = 'panel' AND `varname` = 'no_robots'");
lastStepStatus(0);
showUpdateStep("Adding setting to have all froxlor customers in a local group", true);
Settings::AddNew("system.froxlorusergroup", '');
Settings::AddNew("system.froxlorusergroup_gid", '');
lastStepStatus(0);
\Froxlor\Froxlor::updateToDbVersion('202107300');
}
if (\Froxlor\Froxlor::isDatabaseVersion('202107300')) {
showUpdateStep("Adds the possibility to select the PowerDNS Operation Mode", true);
Settings::AddNew("system.powerdns_mode", 'Native');
lastStepStatus(0);
\Froxlor\Froxlor::updateToDbVersion('202108180');
}
if (\Froxlor\Froxlor::isFroxlorVersion('0.10.27')) {
showUpdateStep("Updating from 0.10.27 to 0.10.28", false);
\Froxlor\Froxlor::updateToVersion('0.10.28');
}
if (\Froxlor\Froxlor::isDatabaseVersion('202108180')) {
showUpdateStep("Adding czech language file", true);
Database::query("INSERT INTO `" . TABLE_PANEL_LANGUAGE . "` SET `language` = '&#268;esk&aacute; republika', `iso` = 'cs', `file` = 'lng/czech.lng.php'");
lastStepStatus(0);
\Froxlor\Froxlor::updateToDbVersion('202109040');
}
if (\Froxlor\Froxlor::isFroxlorVersion('0.10.28')) {
showUpdateStep("Updating from 0.10.28 to 0.10.29", false);
\Froxlor\Froxlor::updateToVersion('0.10.29');
}
if (\Froxlor\Froxlor::isFroxlorVersion('0.10.29')) {
showUpdateStep("Updating from 0.10.29 to 0.10.29.1", false);
\Froxlor\Froxlor::updateToVersion('0.10.29.1');
}

View File

@@ -2505,7 +2505,7 @@ if (\Froxlor\Froxlor::isFroxlorVersion('0.9.30')) {
showUpdateStep("Updating from 0.9.30 to 0.9.31-dev1", true); showUpdateStep("Updating from 0.9.30 to 0.9.31-dev1", true);
lastStepStatus(0); lastStepStatus(0);
showUpdateStep("Removing unsused tables"); showUpdateStep("Removing unused tables");
Database::query("DROP TABLE IF EXISTS `ipsandports_docrootsettings`;"); Database::query("DROP TABLE IF EXISTS `ipsandports_docrootsettings`;");
Database::query("DROP TABLE IF EXISTS `domain_docrootsettings`;"); Database::query("DROP TABLE IF EXISTS `domain_docrootsettings`;");
lastStepStatus(0); lastStepStatus(0);
@@ -2856,7 +2856,7 @@ if (\Froxlor\Froxlor::isFroxlorVersion('0.9.32-rc1')) {
Settings::AddNew("system.croncmdline", $croncmdline); Settings::AddNew("system.croncmdline", $croncmdline);
// add task to generate cron.d-file // add task to generate cron.d-file
\Froxlor\System\Cronjob::inserttask('99'); \Froxlor\System\Cronjob::inserttask('99');
// silenty add the auto-update setting - we do not want everybody to know and use this // silently add the auto-update setting - we do not want everybody to know and use this
// as it is a very dangerous setting // as it is a very dangerous setting
Settings::AddNew("system.cron_allowautoupdate", 0); Settings::AddNew("system.cron_allowautoupdate", 0);
lastStepStatus(0); lastStepStatus(0);
@@ -3872,7 +3872,7 @@ opcache.interned_strings_buffer');
if (\Froxlor\Froxlor::isDatabaseVersion('201801110')) { if (\Froxlor\Froxlor::isDatabaseVersion('201801110')) {
showUpdateStep("Adding php-fpm php PATH setting for envrironment"); showUpdateStep("Adding php-fpm php PATH setting for environment");
Settings::AddNew("phpfpm.envpath", '/usr/local/bin:/usr/bin:/bin'); Settings::AddNew("phpfpm.envpath", '/usr/local/bin:/usr/bin:/bin');
lastStepStatus(0); lastStepStatus(0);

View File

@@ -19,7 +19,7 @@
* Function getPreConfig * Function getPreConfig
* *
* outputs various content before the update process * outputs various content before the update process
* can be continued (askes for agreement whatever is being asked) * can be continued (asks for agreement whatever is being asked)
* *
* @param string $current_version * @param string $current_version
* @param int $current_db_version * @param int $current_db_version

View File

@@ -414,7 +414,7 @@ function parseAndOutputPreconfig(&$has_preconfig, &$return, $current_version, $c
if (Settings::Get('system.webserver') == 'apache2') { if (Settings::Get('system.webserver') == 'apache2') {
$has_preconfig = true; $has_preconfig = true;
$description = 'Froxlor now supports the new Apache 2.4. Please be aware that you need to load additional apache-modules in ordner to use it.<br />'; $description = 'Froxlor now supports the new Apache 2.4. Please be aware that you need to load additional apache-modules in order to use it.<br />';
$description .= '<pre>LoadModule authz_core_module modules/mod_authz_core.so $description .= '<pre>LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_host_module modules/mod_authz_host.so</pre><br />'; LoadModule authz_host_module modules/mod_authz_host.so</pre><br />';
$question = '<strong>Do you want to enable the Apache-2.4 modification?:</strong>&nbsp;'; $question = '<strong>Do you want to enable the Apache-2.4 modification?:</strong>&nbsp;';
@@ -600,8 +600,8 @@ function parseAndOutputPreconfig(&$has_preconfig, &$return, $current_version, $c
if (versionInUpdate($current_version, '0.9.32-rc2')) { if (versionInUpdate($current_version, '0.9.32-rc2')) {
$has_preconfig = true; $has_preconfig = true;
$description = 'To customize the command which executes the cronjob (php - basically) change the path below according to your system.<br /><br />'; $description = 'To customize the command which executes the cronjob (php - basically) change the path below according to your system.<br /><br />';
$question = '<strong>Please specify the command to execute cronscripts</strong> (default: "/usr/bin/nice -n 5 /usr/bin/php5 -q")<br />'; $question = '<strong>Please specify the command to execute cronscripts</strong> (default: "/usr/bin/nice -n 5 /usr/bin/php -q")<br />';
$question .= '<input type="text" class="text" name="croncmdline" value="/usr/bin/nice -n 5 /usr/bin/php5 -q" /><br />'; $question .= '<input type="text" class="text" name="croncmdline" value="/usr/bin/nice -n 5 /usr/bin/php -q" /><br />';
eval("\$return.=\"" . \Froxlor\UI\Template::getTemplate("update/preconfigitem") . "\";"); eval("\$return.=\"" . \Froxlor\UI\Template::getTemplate("update/preconfigitem") . "\";");
} }

4
js/html5shiv.min.js vendored
View File

@@ -1,4 +1,4 @@
/** /**
* @preserve HTML5 Shiv 3.7.2 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed * @preserve HTML5 Shiv 3.7.3 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
*/ */
!function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=t.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=t.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),t.elements=c+" "+a,j(b)}function f(a){var b=s[a[q]];return b||(b={},r++,a[q]=r,s[r]=b),b}function g(a,c,d){if(c||(c=b),l)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():p.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||o.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),l)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return t.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(t,b.frag)}function j(a){a||(a=b);var d=f(a);return!t.shivCSS||k||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),l||i(a,d),a}var k,l,m="3.7.2",n=a.html5||{},o=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,p=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,q="_html5shiv",r=0,s={};!function(){try{var a=b.createElement("a");a.innerHTML="<xyz></xyz>",k="hidden"in a,l=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){k=!0,l=!0}}();var t={elements:n.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:m,shivCSS:n.shivCSS!==!1,supportsUnknownElements:l,shivMethods:n.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=t,j(b)}(this,document); !function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=t.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=t.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),t.elements=c+" "+a,j(b)}function f(a){var b=s[a[q]];return b||(b={},r++,a[q]=r,s[r]=b),b}function g(a,c,d){if(c||(c=b),l)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():p.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||o.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),l)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return t.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(t,b.frag)}function j(a){a||(a=b);var d=f(a);return!t.shivCSS||k||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),l||i(a,d),a}var k,l,m="3.7.3",n=a.html5||{},o=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,p=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,q="_html5shiv",r=0,s={};!function(){try{var a=b.createElement("a");a.innerHTML="<xyz></xyz>",k="hidden"in a,l=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){k=!0,l=!0}}();var t={elements:n.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:m,shivCSS:n.shivCSS!==!1,supportsUnknownElements:l,shivMethods:n.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=t,j(b),"object"==typeof module&&module.exports&&(module.exports=t)}("undefined"!=typeof window?window:this,document);

4
js/jquery.min.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -310,6 +310,13 @@ abstract class ApiCommand extends ApiParameter
} elseif (in_array($valoper['op'], $ops)) { } elseif (in_array($valoper['op'], $ops)) {
$condition .= $field . ' ' . $valoper['op'] . ':' . $cleanfield; $condition .= $field . ' ' . $valoper['op'] . ':' . $cleanfield;
$query_fields[':' . $cleanfield] = $valoper['value'] ?? ''; $query_fields[':' . $cleanfield] = $valoper['value'] ?? '';
} elseif (strtolower($valoper['op']) == 'in' && is_array($valoper['value']) && count($valoper['value']) > 0) {
$condition .= $field . ' ' . $valoper['op'] . ' (';
foreach ($valoper['value'] as $incnt => $invalue) {
$condition .= ":" . $cleanfield . $incnt . ", ";
$query_fields[':' . $cleanfield . $incnt] = $invalue ?? '';
}
$condition = substr($condition, 0, - 2) . ')';
} else { } else {
continue; continue;
} }

View File

@@ -51,7 +51,7 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) { while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) {
$result[] = $row; $result[] = $row;
} }
return $this->response(200, "successfull", array( return $this->response(200, "successful", array(
'count' => count($result), 'count' => count($result),
'list' => $result 'list' => $result
)); ));
@@ -75,7 +75,7 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
"); ");
$result = Database::pexecute_first($result_stmt, null, true, true); $result = Database::pexecute_first($result_stmt, null, true, true);
if ($result) { if ($result) {
return $this->response(200, "successfull", $result['num_admins']); return $this->response(200, "successful", $result['num_admins']);
} }
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
@@ -109,7 +109,7 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
$result = Database::pexecute_first($result_stmt, $params, true, true); $result = Database::pexecute_first($result_stmt, $params, true, true);
if ($result) { if ($result) {
$this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] get admin '" . $result['loginname'] . "'"); $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] get admin '" . $result['loginname'] . "'");
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
$key = ($id > 0 ? "id #" . $id : "loginname '" . $loginname . "'"); $key = ($id > 0 ? "id #" . $id : "loginname '" . $loginname . "'");
throw new \Exception("Admin with " . $key . " could not be found", 404); throw new \Exception("Admin with " . $key . " could not be found", 404);
@@ -231,7 +231,7 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
$idna_convert = new \Froxlor\Idna\IdnaWrapper(); $idna_convert = new \Froxlor\Idna\IdnaWrapper();
$email = $idna_convert->encode(\Froxlor\Validate\Validate::validate($email, 'email', '', '', array(), true)); $email = $idna_convert->encode(\Froxlor\Validate\Validate::validate($email, 'email', '', '', array(), true));
$def_language = \Froxlor\Validate\Validate::validate($def_language, 'default language', '', '', array(), true); $def_language = \Froxlor\Validate\Validate::validate($def_language, 'default language', '', '', array(), true);
$custom_notes = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $custom_notes), 'custom_notes', '/^[^\0]*$/', '', array(), true); $custom_notes = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $custom_notes), 'custom_notes', \Froxlor\Validate\Validate::REGEX_CONF_TEXT, '', array(), true);
if (Settings::Get('system.mail_quota_enabled') != '1') { if (Settings::Get('system.mail_quota_enabled') != '1') {
$email_quota = - 1; $email_quota = - 1;
@@ -364,7 +364,7 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
$result = $this->apiCall('Admins.get', array( $result = $this->apiCall('Admins.get', array(
'id' => $adminid 'id' => $adminid
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
@@ -531,7 +531,7 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
$idna_convert = new \Froxlor\Idna\IdnaWrapper(); $idna_convert = new \Froxlor\Idna\IdnaWrapper();
$email = $idna_convert->encode(\Froxlor\Validate\Validate::validate($email, 'email', '', '', array(), true)); $email = $idna_convert->encode(\Froxlor\Validate\Validate::validate($email, 'email', '', '', array(), true));
$def_language = \Froxlor\Validate\Validate::validate($def_language, 'default language', '', '', array(), true); $def_language = \Froxlor\Validate\Validate::validate($def_language, 'default language', '', '', array(), true);
$custom_notes = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $custom_notes), 'custom_notes', '/^[^\0]*$/', '', array(), true); $custom_notes = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $custom_notes), 'custom_notes', \Froxlor\Validate\Validate::REGEX_CONF_TEXT, '', array(), true);
$theme = \Froxlor\Validate\Validate::validate($theme, 'theme', '', '', array(), true); $theme = \Froxlor\Validate\Validate::validate($theme, 'theme', '', '', array(), true);
$password = \Froxlor\Validate\Validate::validate($password, 'password', '', '', array(), true); $password = \Froxlor\Validate\Validate::validate($password, 'password', '', '', array(), true);
@@ -677,7 +677,7 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
$result = $this->apiCall('Admins.get', array( $result = $this->apiCall('Admins.get', array(
'id' => $result['adminid'] 'id' => $result['adminid']
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
} }
} }
@@ -713,6 +713,10 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
if ($id == $this->getUserDetail('adminid')) { if ($id == $this->getUserDetail('adminid')) {
\Froxlor\UI\Response::standard_error('youcantdeleteyourself', '', true); \Froxlor\UI\Response::standard_error('youcantdeleteyourself', '', true);
} }
// can't delete the first superadmin
if ($id == 1) {
\Froxlor\UI\Response::standard_error('cannotdeletesuperadmin', '', true);
}
// delete admin // delete admin
$del_stmt = Database::prepare(" $del_stmt = Database::prepare("
@@ -730,14 +734,6 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
'adminid' => $id 'adminid' => $id
), true, true); ), true, true);
// delete the diskspace usage
$del_stmt = Database::prepare("
DELETE FROM `" . TABLE_PANEL_DISKSPACE_ADMINS . "` WHERE `adminid` = :adminid
");
Database::pexecute($del_stmt, array(
'adminid' => $id
), true, true);
// set admin-id of the old admin's customer to current admins // set admin-id of the old admin's customer to current admins
$upd_stmt = Database::prepare(" $upd_stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET
@@ -779,7 +775,7 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
$this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "[API] deleted admin '" . $result['loginname'] . "'"); $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "[API] deleted admin '" . $result['loginname'] . "'");
\Froxlor\User::updateCounters(); \Froxlor\User::updateCounters();
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
} }
@@ -821,7 +817,7 @@ class Admins extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
$result['loginfail_count'] = 0; $result['loginfail_count'] = 0;
$this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "[API] unlocked admin '" . $result['loginname'] . "'"); $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "[API] unlocked admin '" . $result['loginname'] . "'");
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
} }

View File

@@ -0,0 +1,30 @@
<?php
namespace Froxlor\Api\Commands;
use Froxlor\Database\Database;
use Froxlor\Settings;
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package API
* @since 0.10.0
*
*/
class ApiKeys extends \Froxlor\Api\ApiCommand
{
public function listing()
{}
public function listingCount()
{}
}

View File

@@ -81,7 +81,7 @@ class Certificates extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou
$result = $this->apiCall('Certificates.get', array( $result = $this->apiCall('Certificates.get', array(
'id' => $domain['id'] 'id' => $domain['id']
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
throw new \Exception("Domain '" . $domain['domain'] . "' already has a certificate. Did you mean to call update?", 406); throw new \Exception("Domain '" . $domain['domain'] . "' already has a certificate. Did you mean to call update?", 406);
} }
@@ -122,7 +122,7 @@ class Certificates extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou
if (! $result) { if (! $result) {
throw new \Exception("Domain '" . $domain['domain'] . "' does not have a certificate.", 412); throw new \Exception("Domain '" . $domain['domain'] . "' does not have a certificate.", 412);
} }
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
/** /**
@@ -168,7 +168,7 @@ class Certificates extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou
$result = $this->apiCall('Certificates.get', array( $result = $this->apiCall('Certificates.get', array(
'id' => $domain['id'] 'id' => $domain['id']
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
/** /**
@@ -189,7 +189,7 @@ class Certificates extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou
*/ */
public function listing() public function listing()
{ {
// select all my (accessable) certificates // select all my (accessible) certificates
$certs_stmt_query = "SELECT s.*, d.domain, d.letsencrypt, c.customerid, c.loginname $certs_stmt_query = "SELECT s.*, d.domain, d.letsencrypt, c.customerid, c.loginname
FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` s FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` s
LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` d ON `d`.`id` = `s`.`domainid` LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` d ON `d`.`id` = `s`.`domainid`
@@ -222,7 +222,7 @@ class Certificates extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou
} }
$result[] = $cert; $result[] = $cert;
} }
return $this->response(200, "successfull", array( return $this->response(200, "successful", array(
'count' => count($result), 'count' => count($result),
'list' => $result 'list' => $result
)); ));
@@ -237,7 +237,7 @@ class Certificates extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou
*/ */
public function listingCount() public function listingCount()
{ {
// select all my (accessable) certificates // select all my (accessible) certificates
$certs_stmt_query = "SELECT COUNT(*) as num_certs $certs_stmt_query = "SELECT COUNT(*) as num_certs
FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` s FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` s
LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` d ON `d`.`id` = `s`.`domainid` LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` d ON `d`.`id` = `s`.`domainid`
@@ -258,7 +258,7 @@ class Certificates extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou
$certs_stmt = Database::prepare($certs_stmt_query); $certs_stmt = Database::prepare($certs_stmt_query);
$result = Database::pexecute_first($certs_stmt, $qry_params, true, true); $result = Database::pexecute_first($certs_stmt, $qry_params, true, true);
if ($result) { if ($result) {
return $this->response(200, "successfull", $result['num_certs']); return $this->response(200, "successful", $result['num_certs']);
} }
} }
@@ -326,7 +326,7 @@ class Certificates extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou
\Froxlor\System\Cronjob::inserttask('12', $chk['domain']); \Froxlor\System\Cronjob::inserttask('12', $chk['domain']);
} }
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_INFO, "[API] removed ssl-certificate for '" . $chk['domain'] . "'"); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_INFO, "[API] removed ssl-certificate for '" . $chk['domain'] . "'");
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
throw new \Exception("Unable to determine SSL certificate. Maybe no access?", 406); throw new \Exception("Unable to determine SSL certificate. Maybe no access?", 406);
} }

View File

@@ -51,7 +51,7 @@ class Cronjobs extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceE
'id' => $id 'id' => $id
), true, true); ), true, true);
if ($result) { if ($result) {
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
throw new \Exception("cronjob with id #" . $id . " could not be found", 404); throw new \Exception("cronjob with id #" . $id . " could not be found", 404);
} }
@@ -119,7 +119,7 @@ class Cronjobs extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceE
$result = $this->apiCall('Cronjobs.get', array( $result = $this->apiCall('Cronjobs.get', array(
'id' => $id 'id' => $id
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
} }
@@ -152,7 +152,7 @@ class Cronjobs extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceE
while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) { while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) {
$result[] = $row; $result[] = $row;
} }
return $this->response(200, "successfull", array( return $this->response(200, "successful", array(
'count' => count($result), 'count' => count($result),
'list' => $result 'list' => $result
)); ));
@@ -175,7 +175,7 @@ class Cronjobs extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceE
"); ");
$result = Database::pexecute_first($result_stmt, null, true, true); $result = Database::pexecute_first($result_stmt, null, true, true);
if ($result) { if ($result) {
return $this->response(200, "successfull", $result['num_crons']); return $this->response(200, "successful", $result['num_crons']);
} }
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);

View File

@@ -23,7 +23,7 @@ class CustomerBackups extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Re
{ {
/** /**
* check whether backup is enabled systemwide and if accessable for customer (hide_options) * check whether backup is enabled systemwide and if accessible for customer (hide_options)
* *
* @throws \Exception * @throws \Exception
*/ */
@@ -52,7 +52,9 @@ class CustomerBackups extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Re
* @param bool $backup_web * @param bool $backup_web
* optional whether to backup web-data, default is 0 (false) * optional whether to backup web-data, default is 0 (false)
* @param int $customerid * @param int $customerid
* required when called as admin, not needed when called as customer * optional, required when called as admin (if $loginname is not specified)
* @param string $loginname
* optional, required when called as admin (if $customerid is not specified)
* *
* @access admin, customer * @access admin, customer
* @throws \Exception * @throws \Exception
@@ -109,7 +111,7 @@ class CustomerBackups extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Re
\Froxlor\System\Cronjob::inserttask('20', $task_data); \Froxlor\System\Cronjob::inserttask('20', $task_data);
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] added customer-backup job for '" . $customer['loginname'] . "'. Target directory: " . $userpath); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] added customer-backup job for '" . $customer['loginname'] . "'. Target directory: " . $userpath);
return $this->response(200, "successfull", $task_data); return $this->response(200, "successful", $task_data);
} }
/** /**
@@ -168,7 +170,7 @@ class CustomerBackups extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Re
} }
} }
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] list customer-backups"); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] list customer-backups");
return $this->response(200, "successfull", array( return $this->response(200, "successful", array(
'count' => count($result), 'count' => count($result),
'list' => $result 'list' => $result
)); ));
@@ -202,7 +204,7 @@ class CustomerBackups extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Re
$result_count ++; $result_count ++;
} }
} }
return $this->response(200, "successfull", $result_count); return $this->response(200, "successful", $result_count);
} }
/** /**
@@ -237,7 +239,7 @@ class CustomerBackups extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Re
'tid' => $entry 'tid' => $entry
), true, true); ), true, true);
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] deleted planned customer-backup #" . $entry); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] deleted planned customer-backup #" . $entry);
return $this->response(200, "successfull", true); return $this->response(200, "successful", true);
} }
} }
} }

View File

@@ -33,6 +33,8 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
* optional specify offset for resultset * optional specify offset for resultset
* @param array $sql_orderby * @param array $sql_orderby
* optional array with index = fieldname and value = ASC|DESC to order the resultset by one or more fields * optional array with index = fieldname and value = ASC|DESC to order the resultset by one or more fields
* @param bool $show_usages
* optional, default false
* *
* @access admin * @access admin
* @throws \Exception * @throws \Exception
@@ -41,6 +43,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
public function listing() public function listing()
{ {
if ($this->isAdmin()) { if ($this->isAdmin()) {
$show_usages = $this->getBoolParam('show_usages', true, false);
$this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] list customers"); $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] list customers");
$query_fields = array(); $query_fields = array();
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
@@ -57,10 +60,50 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
$params = array_merge($params, $query_fields); $params = array_merge($params, $query_fields);
Database::pexecute($result_stmt, $params, true, true); Database::pexecute($result_stmt, $params, true, true);
$result = array(); $result = array();
$domains_stmt = null;
$usages_stmt = null;
if ($show_usages) {
$domains_stmt = Database::prepare("
SELECT COUNT(`id`) AS `domains`
FROM `" . TABLE_PANEL_DOMAINS . "`
WHERE `customerid` = :cid
AND `parentdomainid` = '0'
AND `id`<> :stdd
");
$usages_stmt = Database::prepare("
SELECT * FROM `" . TABLE_PANEL_DISKSPACE . "`
WHERE `customerid` = :cid
ORDER BY `stamp` DESC LIMIT 1
");
}
while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) { while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) {
if ($show_usages) {
// get number of domains
Database::pexecute($domains_stmt, array(
'cid' => $row['customerid'],
'stdd' => $row['standardsubdomain']
));
$domains = $domains_stmt->fetch(\PDO::FETCH_ASSOC);
$row['domains'] = intval($domains['domains']);
// get disk-space usages for web, mysql and mail
$usages = Database::pexecute_first($usages_stmt, array(
'cid' => $row['customerid']
));
if ($usages) {
$row['webspace_used'] = $usages['webspace'];
$row['mailspace_used'] = $usages['mail'];
$row['dbspace_used'] = $usages['mysql'];
} else {
$row['webspace_used'] = 0;
$row['mailspace_used'] = 0;
$row['dbspace_used'] = 0;
}
}
$result[] = $row; $result[] = $row;
} }
return $this->response(200, "successfull", array( return $this->response(200, "successful", array(
'count' => count($result), 'count' => count($result),
'list' => $result 'list' => $result
)); ));
@@ -90,7 +133,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
} }
$result = Database::pexecute_first($result_stmt, $params, true, true); $result = Database::pexecute_first($result_stmt, $params, true, true);
if ($result) { if ($result) {
return $this->response(200, "successfull", $result['num_customers']); return $this->response(200, "successful", $result['num_customers']);
} }
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
@@ -103,6 +146,8 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
* optional, the customer-id * optional, the customer-id
* @param string $loginname * @param string $loginname
* optional, the loginname * optional, the loginname
* @param bool $show_usages
* optional, default false
* *
* @access admin, customer * @access admin, customer
* @throws \Exception * @throws \Exception
@@ -113,6 +158,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
$id = $this->getParam('id', true, 0); $id = $this->getParam('id', true, 0);
$ln_optional = ($id <= 0 ? false : true); $ln_optional = ($id <= 0 ? false : true);
$loginname = $this->getParam('loginname', $ln_optional, ''); $loginname = $this->getParam('loginname', $ln_optional, '');
$show_usages = $this->getBoolParam('show_usages', true, false);
if ($this->isAdmin()) { if ($this->isAdmin()) {
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
@@ -142,8 +188,42 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
if (! $this->isAdmin() && $result['custom_notes_show'] != 1) { if (! $this->isAdmin() && $result['custom_notes_show'] != 1) {
$result['custom_notes'] = ""; $result['custom_notes'] = "";
} }
if ($show_usages) {
// get number of domains
$domains_stmt = Database::prepare("
SELECT COUNT(`id`) AS `domains`
FROM `" . TABLE_PANEL_DOMAINS . "`
WHERE `customerid` = :cid
AND `parentdomainid` = '0'
AND `id`<> :stdd
");
Database::pexecute($domains_stmt, array(
'cid' => $result['customerid'],
'stdd' => $result['standardsubdomain']
));
$domains = $domains_stmt->fetch(\PDO::FETCH_ASSOC);
$result['domains'] = intval($domains['domains']);
// get disk-space usages for web, mysql and mail
$usages_stmt = Database::prepare("
SELECT * FROM `" . TABLE_PANEL_DISKSPACE . "`
WHERE `customerid` = :cid
ORDER BY `stamp` DESC LIMIT 1
");
$usages = Database::pexecute_first($usages_stmt, array(
'cid' => $result['customerid']
));
if ($usages) {
$result['webspace_used'] = $usages['webspace'];
$result['mailspace_used'] = $usages['mail'];
$result['dbspace_used'] = $usages['mysql'];
} else {
$result['webspace_used'] = 0;
$result['mailspace_used'] = 0;
$result['dbspace_used'] = 0;
}
}
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] get customer '" . $result['loginname'] . "'"); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] get customer '" . $result['loginname'] . "'");
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
$key = ($id > 0 ? "id #" . $id : "loginname '" . $loginname . "'"); $key = ($id > 0 ? "id #" . $id : "loginname '" . $loginname . "'");
throw new \Exception("Customer with " . $key . " could not be found", 404); throw new \Exception("Customer with " . $key . " could not be found", 404);
@@ -183,7 +263,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
* optional, whether to show the content of custom_notes to the customer, default 0 (false) * optional, whether to show the content of custom_notes to the customer, default 0 (false)
* @param string $new_loginname * @param string $new_loginname
* optional, if empty generated automatically using customer-prefix and increasing number * optional, if empty generated automatically using customer-prefix and increasing number
* @param string $password * @param string $new_customer_password
* optional, if empty generated automatically and send to the customer's email if $sendpassword is 1 * optional, if empty generated automatically and send to the customer's email if $sendpassword is 1
* @param bool $sendpassword * @param bool $sendpassword
* optional, whether to send the password to the customer after creation, default 0 (false) * optional, whether to send the password to the customer after creation, default 0 (false)
@@ -228,7 +308,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
* @param bool $mysqls_ul * @param bool $mysqls_ul
* optional, whether customer should have unlimited mysql-databases, default 0 (false) * optional, whether customer should have unlimited mysql-databases, default 0 (false)
* @param bool $createstdsubdomain * @param bool $createstdsubdomain
* optional, whether to create a standard-subdomain ([loginname].froxlor-hostname.tld), default 0 (false) * optional, whether to create a standard-subdomain ([loginname].froxlor-hostname.tld), default [system.createstdsubdom_default]
* @param bool $phpenabled * @param bool $phpenabled
* optional, whether to allow usage of PHP, default 0 (false) * optional, whether to allow usage of PHP, default 0 (false)
* @param array $allowed_phpconfigs * @param array $allowed_phpconfigs
@@ -236,9 +316,9 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
* @param bool $perlenabled * @param bool $perlenabled
* optional, whether to allow usage of Perl/CGI, default 0 (false) * optional, whether to allow usage of Perl/CGI, default 0 (false)
* @param bool $dnsenabled * @param bool $dnsenabled
* optional, wether to allow usage of the DNS editor (requires activated nameserver in settings), default 0 (false) * optional, whether to allow usage of the DNS editor (requires activated nameserver in settings), default 0 (false)
* @param bool $logviewenabled * @param bool $logviewenabled
* optional, wether to allow acccess to webserver access/error-logs, default 0 (false) * optional, whether to allow access to webserver access/error-logs, default 0 (false)
* @param bool $store_defaultindex * @param bool $store_defaultindex
* optional, whether to store the default index file to customers homedir * optional, whether to store the default index file to customers homedir
* @param int $hosting_plan_id * @param int $hosting_plan_id
@@ -272,7 +352,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
$gender = (int) $this->getParam('gender', true, 0); $gender = (int) $this->getParam('gender', true, 0);
$custom_notes = $this->getParam('custom_notes', true, ''); $custom_notes = $this->getParam('custom_notes', true, '');
$custom_notes_show = $this->getBoolParam('custom_notes_show', true, 0); $custom_notes_show = $this->getBoolParam('custom_notes_show', true, 0);
$createstdsubdomain = $this->getBoolParam('createstdsubdomain', true, 0); $createstdsubdomain = $this->getBoolParam('createstdsubdomain', true, Settings::Get('system.createstdsubdom_default'));
$password = $this->getParam('new_customer_password', true, ''); $password = $this->getParam('new_customer_password', true, '');
$sendpassword = $this->getBoolParam('sendpassword', true, 0); $sendpassword = $this->getBoolParam('sendpassword', true, 0);
$store_defaultindex = $this->getBoolParam('store_defaultindex', true, 0); $store_defaultindex = $this->getBoolParam('store_defaultindex', true, 0);
@@ -336,7 +416,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
$email = $idna_convert->encode(\Froxlor\Validate\Validate::validate($email, 'email', '', '', array(), true)); $email = $idna_convert->encode(\Froxlor\Validate\Validate::validate($email, 'email', '', '', array(), true));
$customernumber = \Froxlor\Validate\Validate::validate($customernumber, 'customer number', '/^[A-Za-z0-9 \-]*$/Di', '', array(), true); $customernumber = \Froxlor\Validate\Validate::validate($customernumber, 'customer number', '/^[A-Za-z0-9 \-]*$/Di', '', array(), true);
$def_language = \Froxlor\Validate\Validate::validate($def_language, 'default language', '', '', array(), true); $def_language = \Froxlor\Validate\Validate::validate($def_language, 'default language', '', '', array(), true);
$custom_notes = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $custom_notes), 'custom_notes', '/^[^\0]*$/', '', array(), true); $custom_notes = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $custom_notes), 'custom_notes', \Froxlor\Validate\Validate::REGEX_CONF_TEXT, '', array(), true);
if (Settings::Get('system.mail_quota_enabled') != '1') { if (Settings::Get('system.mail_quota_enabled') != '1') {
$email_quota = - 1; $email_quota = - 1;
@@ -743,7 +823,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
$result = $this->apiCall('Customers.get', array( $result = $this->apiCall('Customers.get', array(
'loginname' => $loginname 'loginname' => $loginname
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
throw new \Exception("No more resources available", 406); throw new \Exception("No more resources available", 406);
} }
@@ -843,9 +923,9 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
* @param bool $perlenabled * @param bool $perlenabled
* optional, whether to allow usage of Perl/CGI, default 0 (false) * optional, whether to allow usage of Perl/CGI, default 0 (false)
* @param bool $dnsenabled * @param bool $dnsenabled
* optional, ether to allow usage of the DNS editor (requires activated nameserver in settings), default 0 (false) * optional, whether to allow usage of the DNS editor (requires activated nameserver in settings), default 0 (false)
* @param bool $logviewenabled * @param bool $logviewenabled
* optional, ether to allow acccess to webserver access/error-logs, default 0 (false) * optional, whether to allow access to webserver access/error-logs, default 0 (false)
* @param string $theme * @param string $theme
* optional, change theme * optional, change theme
* *
@@ -873,7 +953,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
$email = $this->getParam('email', true, $idna_convert->decode($result['email'])); $email = $this->getParam('email', true, $idna_convert->decode($result['email']));
$name = $this->getParam('name', true, $result['name']); $name = $this->getParam('name', true, $result['name']);
$firstname = $this->getParam('firstname', true, $result['firstname']); $firstname = $this->getParam('firstname', true, $result['firstname']);
$company_required = (! empty($name) && empty($firstname)) || (empty($name) && ! empty($firstname)) || (empty($name) && empty($firstname)); $company_required = empty($result['company']) && ((! empty($name) && empty($firstname)) || (empty($name) && ! empty($firstname)) || (empty($name) && empty($firstname)));
$company = $this->getParam('company', ($company_required ? false : true), $result['company']); $company = $this->getParam('company', ($company_required ? false : true), $result['company']);
$street = $this->getParam('street', true, $result['street']); $street = $this->getParam('street', true, $result['street']);
$zipcode = $this->getParam('zipcode', true, $result['zipcode']); $zipcode = $this->getParam('zipcode', true, $result['zipcode']);
@@ -928,7 +1008,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
$fax = \Froxlor\Validate\Validate::validate($fax, 'fax', '/^[0-9\- \+\(\)\/]*$/', '', array(), true); $fax = \Froxlor\Validate\Validate::validate($fax, 'fax', '/^[0-9\- \+\(\)\/]*$/', '', array(), true);
$email = $idna_convert->encode(\Froxlor\Validate\Validate::validate($email, 'email', '', '', array(), true)); $email = $idna_convert->encode(\Froxlor\Validate\Validate::validate($email, 'email', '', '', array(), true));
$customernumber = \Froxlor\Validate\Validate::validate($customernumber, 'customer number', '/^[A-Za-z0-9 \-]*$/Di', '', array(), true); $customernumber = \Froxlor\Validate\Validate::validate($customernumber, 'customer number', '/^[A-Za-z0-9 \-]*$/Di', '', array(), true);
$custom_notes = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $custom_notes), 'custom_notes', '/^[^\0]*$/', '', array(), true); $custom_notes = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $custom_notes), 'custom_notes', \Froxlor\Validate\Validate::REGEX_CONF_TEXT, '', array(), true);
if (! empty($allowed_phpconfigs)) { if (! empty($allowed_phpconfigs)) {
$allowed_phpconfigs = array_map('intval', $allowed_phpconfigs); $allowed_phpconfigs = array_map('intval', $allowed_phpconfigs);
} }
@@ -1025,7 +1105,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
\Froxlor\System\Cronjob::inserttask('1'); \Froxlor\System\Cronjob::inserttask('1');
} }
if ($phpenabled != $result['phpenabled'] || $perlenabled != $result['perlenabled']) { if ($phpenabled != $result['phpenabled'] || $perlenabled != $result['perlenabled'] || $email != $result['email']) {
\Froxlor\System\Cronjob::inserttask('1'); \Froxlor\System\Cronjob::inserttask('1');
} }
@@ -1340,7 +1420,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
$result = $this->apiCall('Customers.get', array( $result = $this->apiCall('Customers.get', array(
'id' => $result['customerid'] 'id' => $result['customerid']
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
/** /**
@@ -1411,7 +1491,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
), true, true); ), true, true);
// first gather all domain-id's to clean up panel_domaintoip, dns-entries and certificates accordingly // first gather all domain-id's to clean up panel_domaintoip, dns-entries and certificates accordingly
$did_stmt = Database::prepare("SELECT `id` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `customerid` = :id"); $did_stmt = Database::prepare("SELECT `id`, `domain` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `customerid` = :id");
Database::pexecute($did_stmt, array( Database::pexecute($did_stmt, array(
'id' => $id 'id' => $id
), true, true); ), true, true);
@@ -1431,6 +1511,10 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
Database::pexecute($stmt, array( Database::pexecute($stmt, array(
'did' => $row['id'] 'did' => $row['id']
), true, true); ), true, true);
// remove domains DNS from powerDNS if used, #581
\Froxlor\System\Cronjob::inserttask('11', $row['domain']);
// remove domain from acme.sh / lets encrypt if used
\Froxlor\System\Cronjob::inserttask('12', $row['domain']);
} }
// remove customer domains // remove customer domains
$stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `customerid` = :id"); $stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `customerid` = :id");
@@ -1573,7 +1657,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
\Froxlor\System\Cronjob::inserttask('10'); \Froxlor\System\Cronjob::inserttask('10');
$this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "[API] deleted customer '" . $result['loginname'] . "'"); $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "[API] deleted customer '" . $result['loginname'] . "'");
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
} }
@@ -1615,7 +1699,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
$result['loginfail_count'] = 0; $result['loginfail_count'] = 0;
$this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "[API] unlocked customer '" . $result['loginname'] . "'"); $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "[API] unlocked customer '" . $result['loginname'] . "'");
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
} }
@@ -1685,7 +1769,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
$result = $this->apiCall('Customers.get', array( $result = $this->apiCall('Customers.get', array(
'id' => $c_result['customerid'] 'id' => $c_result['customerid']
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
} }

View File

@@ -26,9 +26,9 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
* add options for a given directory * add options for a given directory
* *
* @param int $customerid * @param int $customerid
* optional, admin-only, the customer-id * optional, required when called as admin (if $loginname is not specified)
* @param string $loginname * @param string $loginname
* optional, admin-only, the loginname * optional, required when called as admin (if $customerid is not specified)
* @param string $path * @param string $path
* path relative to the customer's home-Directory * path relative to the customer's home-Directory
* @param bool $options_indexes * @param bool $options_indexes
@@ -69,7 +69,7 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
$error500path = $this->getParam('error500path', true, ''); $error500path = $this->getParam('error500path', true, '');
// validation // validation
$path = \Froxlor\FileDir::makeCorrectDir(\Froxlor\Validate\Validate::validate($path, 'path', '', '', array(), true)); $path = \Froxlor\FileDir::makeCorrectDir(\Froxlor\Validate\Validate::validate($path, 'path', \Froxlor\Validate\Validate::REGEX_DIR, '', array(), true));
$userpath = $path; $userpath = $path;
$path = \Froxlor\FileDir::makeCorrectDir($customer['documentroot'] . '/' . $path); $path = \Froxlor\FileDir::makeCorrectDir($customer['documentroot'] . '/' . $path);
@@ -128,7 +128,7 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
$result = $this->apiCall('DirOptions.get', array( $result = $this->apiCall('DirOptions.get', array(
'id' => $id 'id' => $id
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
/** /**
@@ -186,7 +186,7 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
$result = Database::pexecute_first($result_stmt, $params, true, true); $result = Database::pexecute_first($result_stmt, $params, true, true);
if ($result) { if ($result) {
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] get directory options for '" . $result['path'] . "'"); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] get directory options for '" . $result['path'] . "'");
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
$key = "id #" . $id; $key = "id #" . $id;
throw new \Exception("Directory option with " . $key . " could not be found", 404); throw new \Exception("Directory option with " . $key . " could not be found", 404);
@@ -198,9 +198,9 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
* @param int $id * @param int $id
* id of dir-protection entry * id of dir-protection entry
* @param int $customerid * @param int $customerid
* optional, admin-only, the customer-id * optional, required when called as admin (if $loginname is not specified)
* @param string $loginname * @param string $loginname
* optional, admin-only, the loginname * optional, required when called as admin (if $customerid is not specified)
* @param bool $options_indexes * @param bool $options_indexes
* optional, activate directory-listing for this path, default 0 (false) * optional, activate directory-listing for this path, default 0 (false)
* @param bool $options_cgi * @param bool $options_cgi
@@ -275,7 +275,7 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
$result = $this->apiCall('DirOptions.get', array( $result = $this->apiCall('DirOptions.get', array(
'id' => $id 'id' => $id
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
/** /**
@@ -315,14 +315,14 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
$result[] = $row; $result[] = $row;
} }
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] list directory-options"); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] list directory-options");
return $this->response(200, "successfull", array( return $this->response(200, "successful", array(
'count' => count($result), 'count' => count($result),
'list' => $result 'list' => $result
)); ));
} }
/** /**
* returns the total number of accessable directory options * returns the total number of accessible directory options
* *
* @param int $customerid * @param int $customerid
* optional, admin-only, select directory-protections of a specific customer by id * optional, admin-only, select directory-protections of a specific customer by id
@@ -347,7 +347,7 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
"); ");
$result = Database::pexecute_first($result_stmt, null, true, true); $result = Database::pexecute_first($result_stmt, null, true, true);
if ($result) { if ($result) {
return $this->response(200, "successfull", $result['num_htaccess']); return $this->response(200, "successful", $result['num_htaccess']);
} }
} }
@@ -414,7 +414,7 @@ class DirOptions extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
), true, true); ), true, true);
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_INFO, "[API] deleted directory-option for '" . str_replace($customer_data['documentroot'], '/', $result['path']) . "'"); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_INFO, "[API] deleted directory-option for '" . str_replace($customer_data['documentroot'], '/', $result['path']) . "'");
\Froxlor\System\Cronjob::inserttask('1'); \Froxlor\System\Cronjob::inserttask('1');
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
/** /**

View File

@@ -26,9 +26,9 @@ class DirProtections extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Res
* add htaccess protection to a given directory * add htaccess protection to a given directory
* *
* @param int $customerid * @param int $customerid
* optional, admin-only, the customer-id * optional, required when called as admin (if $loginname is not specified)
* @param string $loginname * @param string $loginname
* optional, admin-only, the loginname * optional, required when called as admin (if $customerid is not specified)
* @param string $path * @param string $path
* @param string $username * @param string $username
* @param string $directory_password * @param string $directory_password
@@ -60,7 +60,7 @@ class DirProtections extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Res
$authname = $this->getParam('directory_authname', true, ''); $authname = $this->getParam('directory_authname', true, '');
// validation // validation
$path = \Froxlor\FileDir::makeCorrectDir(\Froxlor\Validate\Validate::validate($path, 'path', '', '', array(), true)); $path = \Froxlor\FileDir::makeCorrectDir(\Froxlor\Validate\Validate::validate($path, 'path', \Froxlor\Validate\Validate::REGEX_DIR, '', array(), true));
$path = \Froxlor\FileDir::makeCorrectDir($customer['documentroot'] . '/' . $path); $path = \Froxlor\FileDir::makeCorrectDir($customer['documentroot'] . '/' . $path);
$username = \Froxlor\Validate\Validate::validate($username, 'username', '/^[a-zA-Z0-9][a-zA-Z0-9\-_]+\$?$/', '', array(), true); $username = \Froxlor\Validate\Validate::validate($username, 'username', '/^[a-zA-Z0-9][a-zA-Z0-9\-_]+\$?$/', '', array(), true);
$authname = \Froxlor\Validate\Validate::validate($authname, 'directory_authname', '/^[a-zA-Z0-9][a-zA-Z0-9\-_ ]+\$?$/', '', array(), true); $authname = \Froxlor\Validate\Validate::validate($authname, 'directory_authname', '/^[a-zA-Z0-9][a-zA-Z0-9\-_ ]+\$?$/', '', array(), true);
@@ -111,7 +111,7 @@ class DirProtections extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Res
$result = $this->apiCall('DirProtections.get', array( $result = $this->apiCall('DirProtections.get', array(
'id' => $id 'id' => $id
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
/** /**
@@ -173,7 +173,7 @@ class DirProtections extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Res
$result = Database::pexecute_first($result_stmt, $params, true, true); $result = Database::pexecute_first($result_stmt, $params, true, true);
if ($result) { if ($result) {
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] get directory protection for '" . $result['path'] . "'"); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] get directory protection for '" . $result['path'] . "'");
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
$key = ($id > 0 ? "id #" . $id : "username '" . $username . "'"); $key = ($id > 0 ? "id #" . $id : "username '" . $username . "'");
throw new \Exception("Directory protection with " . $key . " could not be found", 404); throw new \Exception("Directory protection with " . $key . " could not be found", 404);
@@ -187,9 +187,9 @@ class DirProtections extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Res
* @param string $username * @param string $username
* optional, the username * optional, the username
* @param int $customerid * @param int $customerid
* optional, admin-only, the customer-id * optional, required when called as admin (if $loginname is not specified)
* @param string $loginname * @param string $loginname
* optional, admin-only, the loginname * optional, required when called as admin (if $customerid is not specified)
* @param string $directory_password * @param string $directory_password
* optional, leave empty for no change * optional, leave empty for no change
* @param string $directory_authname * @param string $directory_authname
@@ -258,7 +258,7 @@ class DirProtections extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Res
$result = $this->apiCall('DirProtections.get', array( $result = $this->apiCall('DirProtections.get', array(
'id' => $result['id'] 'id' => $result['id']
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
/** /**
@@ -298,14 +298,14 @@ class DirProtections extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Res
$result[] = $row; $result[] = $row;
} }
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] list directory-protections"); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] list directory-protections");
return $this->response(200, "successfull", array( return $this->response(200, "successful", array(
'count' => count($result), 'count' => count($result),
'list' => $result 'list' => $result
)); ));
} }
/** /**
* returns the total number of accessable directory protections * returns the total number of accessible directory protections
* *
* @param int $customerid * @param int $customerid
* optional, admin-only, select directory-protections of a specific customer by id * optional, admin-only, select directory-protections of a specific customer by id
@@ -330,7 +330,7 @@ class DirProtections extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Res
"); ");
$result = Database::pexecute_first($result_stmt, null, true, true); $result = Database::pexecute_first($result_stmt, null, true, true);
if ($result) { if ($result) {
return $this->response(200, "successfull", $result['num_htpasswd']); return $this->response(200, "successful", $result['num_htpasswd']);
} }
} }
@@ -386,6 +386,6 @@ class DirProtections extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Res
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_INFO, "[API] deleted htpasswd for '" . $result['username'] . " (" . $result['path'] . ")'"); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_INFO, "[API] deleted htpasswd for '" . $result['username'] . " (" . $result['path'] . ")'");
\Froxlor\System\Cronjob::inserttask('1'); \Froxlor\System\Cronjob::inserttask('1');
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
} }

View File

@@ -136,8 +136,24 @@ class DomainZones extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
// types // types
if ($type == 'A' && filter_var($content, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === false) { if ($type == 'A' && filter_var($content, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === false) {
$errors[] = $this->lng['error']['dns_arec_noipv4']; $errors[] = $this->lng['error']['dns_arec_noipv4'];
} elseif ($type == 'A') {
// check whether there is a CNAME-record for the same resource
foreach ($dom_entries as $existing_entries) {
if ($existing_entries['type'] == 'CNAME' && $existing_entries['record'] == $record) {
$errors[] = $this->lng['error']['dns_other_nomorerr'];
break;
}
}
} elseif ($type == 'AAAA' && filter_var($content, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false) { } elseif ($type == 'AAAA' && filter_var($content, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false) {
$errors[] = $this->lng['error']['dns_aaaarec_noipv6']; $errors[] = $this->lng['error']['dns_aaaarec_noipv6'];
} elseif ($type == 'AAAA') {
// check whether there is a CNAME-record for the same resource
foreach ($dom_entries as $existing_entries) {
if ($existing_entries['type'] == 'CNAME' && $existing_entries['record'] == $record) {
$errors[] = $this->lng['error']['dns_other_nomorerr'];
break;
}
}
} elseif ($type == 'CAA' && ! empty($content)) { } elseif ($type == 'CAA' && ! empty($content)) {
$re = '/(?\'critical\'\d)\h*(?\'type\'iodef|issue|issuewild)\h*(?\'value\'(?\'issuevalue\'"(?\'domain\'(?=.{3,128}$)(?>(?>[a-zA-Z0-9]+[a-zA-Z0-9-]*[a-zA-Z0-9]+|[a-zA-Z0-9]+)\.)*(?>[a-zA-Z]{2,}|[a-zA-Z0-9]{2,}\.[a-zA-Z]{2,}))[;\h]*(?\'parameters\'(?>[a-zA-Z0-9]{1,60}=[a-zA-Z0-9]{1,60}\h*)+)?")|(?\'iodefvalue\'"(?\'url\'(mailto:.*|http:\/\/.*|https:\/\/.*))"))/'; $re = '/(?\'critical\'\d)\h*(?\'type\'iodef|issue|issuewild)\h*(?\'value\'(?\'issuevalue\'"(?\'domain\'(?=.{3,128}$)(?>(?>[a-zA-Z0-9]+[a-zA-Z0-9-]*[a-zA-Z0-9]+|[a-zA-Z0-9]+)\.)*(?>[a-zA-Z]{2,}|[a-zA-Z0-9]{2,}\.[a-zA-Z]{2,}))[;\h]*(?\'parameters\'(?>[a-zA-Z0-9]{1,60}=[a-zA-Z0-9]{1,60}\h*)+)?")|(?\'iodefvalue\'"(?\'url\'(mailto:.*|http:\/\/.*|https:\/\/.*))"))/';
preg_match($re, $content, $matches); preg_match($re, $content, $matches);
@@ -170,6 +186,10 @@ class DomainZones extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
break; break;
} }
} }
// check www-alias setting
if ($result['wwwserveralias'] == '1' && $result['iswildcarddomain'] == '0' && $record == 'www') {
$errors[] = $this->lng['error']['no_wwwcnamae_ifwwwalias'];
}
} }
// append trailing dot (again) // append trailing dot (again)
$content .= '.'; $content .= '.';
@@ -194,6 +214,10 @@ class DomainZones extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
$errors[] = $this->lng['error']['dns_mx_noalias']; $errors[] = $this->lng['error']['dns_mx_noalias'];
break; break;
} }
elseif ($existing_entries['type'] == 'CNAME' && $existing_entries['record'] == $record) {
$errors[] = $this->lng['error']['dns_other_nomorerr'];
break;
}
} }
} }
// append trailing dot (again) // append trailing dot (again)
@@ -206,6 +230,14 @@ class DomainZones extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
} }
if (! \Froxlor\Validate\Validate::validateDomain($content)) { if (! \Froxlor\Validate\Validate::validateDomain($content)) {
$errors[] = $this->lng['error']['dns_ns_invaliddom']; $errors[] = $this->lng['error']['dns_ns_invaliddom'];
} else {
// check whether there is a CNAME-record for the same resource
foreach ($dom_entries as $existing_entries) {
if ($existing_entries['type'] == 'CNAME' && $existing_entries['record'] == $record) {
$errors[] = $this->lng['error']['dns_other_nomorerr'];
break;
}
}
} }
// append trailing dot (again) // append trailing dot (again)
$content .= '.'; $content .= '.';
@@ -309,10 +341,10 @@ class DomainZones extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
$result = $this->apiCall('DomainZones.get', array( $result = $this->apiCall('DomainZones.get', array(
'id' => $id 'id' => $id
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
// return $errors // return $errors
throw new \Exception(implode("\n", $errors)); throw new \Exception(implode("\n", $errors), 406);
} }
/** /**
@@ -360,7 +392,7 @@ class DomainZones extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
$zonefile = (string) $zone; $zonefile = (string) $zone;
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] get dns-zone for '" . $result['domain'] . "'"); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] get dns-zone for '" . $result['domain'] . "'");
return $this->response(200, "successfull", explode("\n", $zonefile)); return $this->response(200, "successful", explode("\n", $zonefile));
} }
/** /**
@@ -420,7 +452,7 @@ class DomainZones extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
while ($row = $sel_stmt->fetch(\PDO::FETCH_ASSOC)) { while ($row = $sel_stmt->fetch(\PDO::FETCH_ASSOC)) {
$result[] = $row; $result[] = $row;
} }
return $this->response(200, "successfull", array( return $this->response(200, "successful", array(
'count' => count($result), 'count' => count($result),
'list' => $result 'list' => $result
)); ));
@@ -464,7 +496,7 @@ class DomainZones extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
'did' => $id 'did' => $id
), true, true); ), true, true);
if ($result) { if ($result) {
return $this->response(200, "successfull", $result['num_dns']); return $this->response(200, "successful", $result['num_dns']);
} }
} }
@@ -511,8 +543,8 @@ class DomainZones extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
if ($del_stmt->rowCount() > 0) { if ($del_stmt->rowCount() > 0) {
// re-generate bind configs // re-generate bind configs
\Froxlor\System\Cronjob::inserttask('4'); \Froxlor\System\Cronjob::inserttask('4');
return $this->response(200, "successfull", true); return $this->response(200, "successful", true);
} }
return $this->response(304, "successfull", true); return $this->response(304, "successful", true);
} }
} }

View File

@@ -68,7 +68,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
} }
$result[] = $row; $result[] = $row;
} }
return $this->response(200, "successfull", array( return $this->response(200, "successful", array(
'count' => count($result), 'count' => count($result),
'list' => $result 'list' => $result
)); ));
@@ -77,7 +77,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
} }
/** /**
* returns the total number of accessable domains * returns the total number of accessible domains
* *
* @access admin * @access admin
* @throws \Exception * @throws \Exception
@@ -100,7 +100,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
} }
$result = Database::pexecute_first($result_stmt, $params, true, true); $result = Database::pexecute_first($result_stmt, $params, true, true);
if ($result) { if ($result) {
return $this->response(200, "successfull", $result['num_domains']); return $this->response(200, "successful", $result['num_domains']);
} }
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
@@ -156,7 +156,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
$result['ipsandports'] = $this->getIpsForDomain($result['id']); $result['ipsandports'] = $this->getIpsForDomain($result['id']);
} }
$this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] get domain '" . $result['domain'] . "'"); $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] get domain '" . $result['domain'] . "'");
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
$key = ($id > 0 ? "id #" . $id : "domainname '" . $domainname . "'"); $key = ($id > 0 ? "id #" . $id : "domainname '" . $domainname . "'");
throw new \Exception("Domain with " . $key . " could not be found", 404); throw new \Exception("Domain with " . $key . " could not be found", 404);
@@ -193,12 +193,36 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
return $ipandports; return $ipandports;
} }
/**
* get ips from array of id's
*
* @param array $ips
* @return array
*/
private function getIpsFromIdArray(array $ids)
{
$resultips_stmt = Database::prepare("
SELECT `ip` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE id = :id
");
$result = [];
foreach ($ids as $id) {
$entry = Database::pexecute_first($resultips_stmt, array(
'id' => $id
));
$result[] = $entry['ip'];
}
return $result;
}
/** /**
* add new domain entry * add new domain entry
* *
* @param string $domain * @param string $domain
* domain-name * domain-name
* @param int $customerid * @param int $customerid
* optional, required when called as admin (if $loginname is not specified)
* @param string $loginname
* optional, required when called as admin (if $customerid is not specified)
* @param int $adminid * @param int $adminid
* optional, default is the calling admin's ID * optional, default is the calling admin's ID
* @param array $ipandport * @param array $ipandport
@@ -210,7 +234,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
* @param bool $email_only * @param bool $email_only
* optional, restrict domain to email usage, default 0 (false) * optional, restrict domain to email usage, default 0 (false)
* @param int $selectserveralias * @param int $selectserveralias
* optional, 0 = wildcard, 1 = www-alias, 2 = none, default 0 * optional, 0 = wildcard, 1 = www-alias, 2 = none, default [system.domaindefaultalias]
* @param bool $speciallogfile * @param bool $speciallogfile
* optional, whether to create an exclusive web-logfile for this domain, default 0 (false) * optional, whether to create an exclusive web-logfile for this domain, default 0 (false)
* @param int $alias * @param int $alias
@@ -285,6 +309,8 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
* optional list of allowed/used ssl/tls ciphers, see system.ssl_cipher_list setting, only used/required if $override_tls is true, default empty or system.ssl_cipher_list setting if $override_tls is true * optional list of allowed/used ssl/tls ciphers, see system.ssl_cipher_list setting, only used/required if $override_tls is true, default empty or system.ssl_cipher_list setting if $override_tls is true
* @param string $tlsv13_cipher_list * @param string $tlsv13_cipher_list
* optional list of allowed/used tls-1.3 specific ciphers, see system.tlsv13_cipher_list setting, only used/required if $override_tls is true, default empty or system.tlsv13_cipher_list setting if $override_tls is true * optional list of allowed/used tls-1.3 specific ciphers, see system.tlsv13_cipher_list setting, only used/required if $override_tls is true, default empty or system.tlsv13_cipher_list setting if $override_tls is true
* @param string $description
* optional custom description (currently not used/shown in the frontend), default empty
* *
* @access admin * @access admin
* @throws \Exception * @throws \Exception
@@ -297,7 +323,6 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
// parameters // parameters
$p_domain = $this->getParam('domain'); $p_domain = $this->getParam('domain');
$customerid = intval($this->getParam('customerid'));
// optional parameters // optional parameters
$p_ipandports = $this->getParam('ipandport', true, explode(',', Settings::Get('system.defaultip'))); $p_ipandports = $this->getParam('ipandport', true, explode(',', Settings::Get('system.defaultip')));
@@ -305,7 +330,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
$subcanemaildomain = $this->getParam('subcanemaildomain', true, 0); $subcanemaildomain = $this->getParam('subcanemaildomain', true, 0);
$isemaildomain = $this->getBoolParam('isemaildomain', true, 0); $isemaildomain = $this->getBoolParam('isemaildomain', true, 0);
$email_only = $this->getBoolParam('email_only', true, 0); $email_only = $this->getBoolParam('email_only', true, 0);
$serveraliasoption = $this->getParam('selectserveralias', true, 0); $serveraliasoption = $this->getParam('selectserveralias', true, Settings::Get('system.domaindefaultalias'));
$speciallogfile = $this->getBoolParam('speciallogfile', true, 0); $speciallogfile = $this->getBoolParam('speciallogfile', true, 0);
$aliasdomain = intval($this->getParam('alias', true, 0)); $aliasdomain = intval($this->getParam('alias', true, 0));
$issubof = $this->getParam('issubof', true, 0); $issubof = $this->getParam('issubof', true, 0);
@@ -352,6 +377,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
$tlsv13_cipher_list = $this->getParam('tlsv13_cipher_list', true, Settings::Get('system.tlsv13_cipher_list')); $tlsv13_cipher_list = $this->getParam('tlsv13_cipher_list', true, Settings::Get('system.tlsv13_cipher_list'));
} }
} }
$description = $this->getParam('description', true, '');
// validation // validation
$p_domain = strtolower($p_domain); $p_domain = strtolower($p_domain);
@@ -377,9 +403,8 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
), '', true); ), '', true);
} }
$customer = $this->apiCall('Customers.get', array( $customer = $this->getCustomerData();
'id' => $customerid $customerid = $customer['customerid'];
));
if ($this->getUserDetail('customers_see_all') == '1' && $adminid != $this->getUserDetail('adminid')) { if ($this->getUserDetail('customers_see_all') == '1' && $adminid != $this->getUserDetail('adminid')) {
$admin_stmt = Database::prepare(" $admin_stmt = Database::prepare("
@@ -428,8 +453,8 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
$zonefile = ''; $zonefile = '';
} }
$specialsettings = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $specialsettings), 'specialsettings', '/^[^\0]*$/', '', array(), true); $specialsettings = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $specialsettings), 'specialsettings', \Froxlor\Validate\Validate::REGEX_CONF_TEXT, '', array(), true);
\Froxlor\Validate\Validate::validate($documentroot, 'documentroot', '', '', array(), true); \Froxlor\Validate\Validate::validate($documentroot, 'documentroot', \Froxlor\Validate\Validate::REGEX_DIR, '', array(), true);
// If path is empty and 'Use domain name as default value for DocumentRoot path' is enabled in settings, // If path is empty and 'Use domain name as default value for DocumentRoot path' is enabled in settings,
// set default path to subdomain or domain name // set default path to subdomain or domain name
@@ -570,6 +595,15 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
$include_specialsettings = 0; $include_specialsettings = 0;
} }
// validate dns if lets encrypt is enabled to check whether we can use it at all
if ($letsencrypt == '1' && Settings::Get('system.le_domain_dnscheck') == '1') {
$domain_ips = \Froxlor\PhpHelper::gethostbynamel6($domain);
$selected_ips = $this->getIpsFromIdArray($ssl_ipandports);
if ($domain_ips == false || count(array_intersect($selected_ips, $domain_ips)) <= 0) {
\Froxlor\UI\Response::standard_error('invaliddnsforletsencrypt', '', true);
}
}
// We can't enable let's encrypt for wildcard-domains // We can't enable let's encrypt for wildcard-domains
if ($serveraliasoption == '0' && $letsencrypt == '1') { if ($serveraliasoption == '0' && $letsencrypt == '1') {
\Froxlor\UI\Response::standard_error('nowildcardwithletsencrypt', '', true); \Froxlor\UI\Response::standard_error('nowildcardwithletsencrypt', '', true);
@@ -727,7 +761,8 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
'tlsv13_cipher_list' => $tlsv13_cipher_list, 'tlsv13_cipher_list' => $tlsv13_cipher_list,
'sslenabled' => $sslenabled, 'sslenabled' => $sslenabled,
'honorcipherorder' => $honorcipherorder, 'honorcipherorder' => $honorcipherorder,
'sessiontickets' => $sessiontickets 'sessiontickets' => $sessiontickets,
'description' => $description
); );
$ins_stmt = Database::prepare(" $ins_stmt = Database::prepare("
@@ -779,7 +814,8 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
`tlsv13_cipher_list` = :tlsv13_cipher_list, `tlsv13_cipher_list` = :tlsv13_cipher_list,
`ssl_enabled` = :sslenabled, `ssl_enabled` = :sslenabled,
`ssl_honorcipherorder` = :honorcipherorder, `ssl_honorcipherorder` = :honorcipherorder,
`ssl_sessiontickets`= :sessiontickets `ssl_sessiontickets` = :sessiontickets,
`description` = :description
"); ");
Database::pexecute($ins_stmt, $ins_data, true, true); Database::pexecute($ins_stmt, $ins_data, true, true);
$domainid = Database::lastInsertId(); $domainid = Database::lastInsertId();
@@ -828,7 +864,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
$result = $this->apiCall('Domains.get', array( $result = $this->apiCall('Domains.get', array(
'domainname' => $domain 'domainname' => $domain
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
} }
throw new \Exception("No more resources available", 406); throw new \Exception("No more resources available", 406);
@@ -844,7 +880,9 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
* @param string $domainname * @param string $domainname
* optional, the domainname * optional, the domainname
* @param int $customerid * @param int $customerid
* optional customer-id * required (if $loginname is not specified)
* @param string $loginname
* required (if $customerid is not specified)
* @param int $adminid * @param int $adminid
* optional, default is the calling admin's ID * optional, default is the calling admin's ID
* @param array $ipandport * @param array $ipandport
@@ -929,6 +967,8 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
* optional whether to honor the (server) cipher order for this domain. default 0 (false), requires SSL * optional whether to honor the (server) cipher order for this domain. default 0 (false), requires SSL
* @param bool $sessiontickets * @param bool $sessiontickets
* optional whether to enable or disable TLS sessiontickets (RFC 5077) for this domain. default 1 (true), requires SSL * optional whether to enable or disable TLS sessiontickets (RFC 5077) for this domain. default 1 (true), requires SSL
* @param string $description
* optional custom description (currently not used/shown in the frontend), default empty
* *
* @access admin * @access admin
* @throws \Exception * @throws \Exception
@@ -952,9 +992,18 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
// optional parameters // optional parameters
$p_ipandports = $this->getParam('ipandport', true, array()); $p_ipandports = $this->getParam('ipandport', true, array());
$customerid = intval($this->getParam('customerid', true, $result['customerid']));
$adminid = intval($this->getParam('adminid', true, $result['adminid'])); $adminid = intval($this->getParam('adminid', true, $result['adminid']));
if ($this->getParam('customerid', true, 0) == 0 && $this->getParam('loginname', true, '') == '') {
$customerid = $result['customerid'];
$customer = $this->apiCall('Customers.get', array(
'id' => $customerid
));
} else {
$customer = $this->getCustomerData();
$customerid = $customer['customerid'];
}
$subcanemaildomain = $this->getParam('subcanemaildomain', true, $result['subcanemaildomain']); $subcanemaildomain = $this->getParam('subcanemaildomain', true, $result['subcanemaildomain']);
$isemaildomain = $this->getBoolParam('isemaildomain', true, $result['isemaildomain']); $isemaildomain = $this->getBoolParam('isemaildomain', true, $result['isemaildomain']);
$email_only = $this->getBoolParam('email_only', true, $result['email_only']); $email_only = $this->getBoolParam('email_only', true, $result['email_only']);
@@ -1015,6 +1064,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
$ssl_cipher_list = $result['ssl_cipher_list']; $ssl_cipher_list = $result['ssl_cipher_list'];
$tlsv13_cipher_list = $result['tlsv13_cipher_list']; $tlsv13_cipher_list = $result['tlsv13_cipher_list'];
} }
$description = $this->getParam('description', true, $result['description']);
// count subdomain usage of source-domain // count subdomain usage of source-domain
$subdomains_stmt = Database::prepare(" $subdomains_stmt = Database::prepare("
@@ -1085,13 +1135,6 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
if (empty($customer) || $customer['customerid'] != $customerid) { if (empty($customer) || $customer['customerid'] != $customerid) {
\Froxlor\UI\Response::standard_error('customerdoesntexist', '', true); \Froxlor\UI\Response::standard_error('customerdoesntexist', '', true);
} }
} else {
$customerid = $result['customerid'];
// get customer
$customer = $this->apiCall('Customers.get', array(
'id' => $customerid
));
} }
// handle change of admin (move domain from admin to admin) // handle change of admin (move domain from admin to admin)
@@ -1157,8 +1200,8 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
$dkim = $result['dkim']; $dkim = $result['dkim'];
} }
$specialsettings = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $specialsettings), 'specialsettings', '/^[^\0]*$/', '', array(), true); $specialsettings = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $specialsettings), 'specialsettings', \Froxlor\Validate\Validate::REGEX_CONF_TEXT, '', array(), true);
$documentroot = \Froxlor\Validate\Validate::validate($documentroot, 'documentroot', '', '', array(), true); $documentroot = \Froxlor\Validate\Validate::validate($documentroot, 'documentroot', \Froxlor\Validate\Validate::REGEX_DIR, '', array(), true);
// when moving customer and no path is specified, update would normally reuse the current document-root // when moving customer and no path is specified, update would normally reuse the current document-root
// which would point to the wrong customer, therefore we will re-create that directory // which would point to the wrong customer, therefore we will re-create that directory
@@ -1313,6 +1356,15 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
$include_specialsettings = 0; $include_specialsettings = 0;
} }
// validate dns if lets encrypt is enabled to check whether we can use it at all
if ($letsencrypt == '1' && Settings::Get('system.le_domain_dnscheck') == '1') {
$domain_ips = \Froxlor\PhpHelper::gethostbynamel6($result['domain']);
$selected_ips = $this->getIpsFromIdArray($ssl_ipandports);
if ($domain_ips == false || count(array_intersect($selected_ips, $domain_ips)) <= 0) {
\Froxlor\UI\Response::standard_error('invaliddnsforletsencrypt', '', true);
}
}
// We can't enable let's encrypt for wildcard-domains // We can't enable let's encrypt for wildcard-domains
if ($serveraliasoption == '0' && $letsencrypt == '1') { if ($serveraliasoption == '0' && $letsencrypt == '1') {
\Froxlor\UI\Response::standard_error('nowildcardwithletsencrypt', '', true); \Froxlor\UI\Response::standard_error('nowildcardwithletsencrypt', '', true);
@@ -1324,8 +1376,13 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
} }
if (! preg_match('/^https?\:\/\//', $documentroot)) { if (! preg_match('/^https?\:\/\//', $documentroot)) {
if ($documentroot != $result['documentroot']) {
if (substr($documentroot, 0, 1) != "/") {
$documentroot = $customer['documentroot'] . '/' . $documentroot;
}
$documentroot = \Froxlor\FileDir::makeCorrectDir($documentroot); $documentroot = \Froxlor\FileDir::makeCorrectDir($documentroot);
} }
}
if ($email_only == '1') { if ($email_only == '1') {
$isemaildomain = '1'; $isemaildomain = '1';
@@ -1442,6 +1499,8 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
Database::pexecute($del_stmt, array( Database::pexecute($del_stmt, array(
'id' => $id 'id' => $id
), true, true); ), true, true);
// remove domain from acme.sh / lets encrypt if used
\Froxlor\System\Cronjob::inserttask('12', $result['domain']);
} }
$updatechildren = ''; $updatechildren = '';
@@ -1577,6 +1636,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
$update_data['sslenabled'] = $sslenabled; $update_data['sslenabled'] = $sslenabled;
$update_data['honorcipherorder'] = $honorcipherorder; $update_data['honorcipherorder'] = $honorcipherorder;
$update_data['sessiontickets'] = $sessiontickets; $update_data['sessiontickets'] = $sessiontickets;
$update_data['description'] = $description;
$update_data['id'] = $id; $update_data['id'] = $id;
$update_stmt = Database::prepare(" $update_stmt = Database::prepare("
@@ -1622,7 +1682,8 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
`tlsv13_cipher_list` = :tlsv13_cipher_list, `tlsv13_cipher_list` = :tlsv13_cipher_list,
`ssl_enabled` = :sslenabled, `ssl_enabled` = :sslenabled,
`ssl_honorcipherorder` = :honorcipherorder, `ssl_honorcipherorder` = :honorcipherorder,
`ssl_sessiontickets` = :sessiontickets `ssl_sessiontickets` = :sessiontickets,
`description` = :description
WHERE `id` = :id WHERE `id` = :id
"); ");
Database::pexecute($update_stmt, $update_data, true, true); Database::pexecute($update_stmt, $update_data, true, true);
@@ -1680,9 +1741,6 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
"); ");
Database::pexecute($_update_stmt, $_update_data, true, true); Database::pexecute($_update_stmt, $_update_data, true, true);
// insert a rebuild-task
\Froxlor\System\Cronjob::inserttask('1');
// Cleanup domain <-> ip mapping // Cleanup domain <-> ip mapping
$del_stmt = Database::prepare(" $del_stmt = Database::prepare("
DELETE FROM `" . TABLE_DOMAINTOIP . "` WHERE `id_domain` = :id DELETE FROM `" . TABLE_DOMAINTOIP . "` WHERE `id_domain` = :id
@@ -1766,7 +1824,10 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
$idna_convert = new \Froxlor\Idna\IdnaWrapper(); $idna_convert = new \Froxlor\Idna\IdnaWrapper();
$this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "[API] updated domain '" . $idna_convert->decode($result['domain']) . "'"); $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "[API] updated domain '" . $idna_convert->decode($result['domain']) . "'");
return $this->response(200, "successfull", $update_data); $result = $this->apiCall('Domains.get', array(
'domainname' => $result['domain']
));
return $this->response(200, "successful", $result);
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
} }
@@ -1927,7 +1988,7 @@ class Domains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
\Froxlor\System\Cronjob::inserttask('1'); \Froxlor\System\Cronjob::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('4'); \Froxlor\System\Cronjob::inserttask('4');
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
} }

View File

@@ -30,9 +30,9 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
* @param string $emailaddr * @param string $emailaddr
* optional email-address to add the account for * optional email-address to add the account for
* @param int $customerid * @param int $customerid
* optional, admin-only, the customer-id * optional, required when called as admin (if $loginname is not specified)
* @param string $loginname * @param string $loginname
* optional, admin-only, the loginname * optional, required when called as admin (if $customerid is not specified)
* @param string $email_password * @param string $email_password
* password for the account * password for the account
* @param string $alternative_email * @param string $alternative_email
@@ -192,7 +192,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
$replace_arr = array( $replace_arr = array(
'EMAIL' => $email_full, 'EMAIL' => $email_full,
'USERNAME' => $username, 'USERNAME' => $username,
'PASSWORD' => $password, 'PASSWORD' => htmlentities(htmlentities($password)),
'SALUTATION' => \Froxlor\User::getCorrectUserSalutation($customer), 'SALUTATION' => \Froxlor\User::getCorrectUserSalutation($customer),
'NAME' => $customer['name'], 'NAME' => $customer['name'],
'FIRSTNAME' => $customer['firstname'], 'FIRSTNAME' => $customer['firstname'],
@@ -273,7 +273,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
$result = $this->apiCall('Emails.get', array( $result = $this->apiCall('Emails.get', array(
'emailaddr' => $result['email_full'] 'emailaddr' => $result['email_full']
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
throw new \Exception("No more resources available", 406); throw new \Exception("No more resources available", 406);
} }
@@ -295,13 +295,15 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
* @param string $emailaddr * @param string $emailaddr
* optional, the email-address to update * optional, the email-address to update
* @param int $customerid * @param int $customerid
* optional, admin-only, the customer-id * optional, required when called as admin (if $loginname is not specified)
* @param string $loginname * @param string $loginname
* optional, admin-only, the loginname * optional, required when called as admin (if $customerid is not specified)
* @param int $email_quota * @param int $email_quota
* optional, update quota * optional, update quota
* @param string $email_password * @param string $email_password
* optional, update password * optional, update password
* @param bool $deactivated
* optional, admin-only
* *
* @access admin, customer * @access admin, customer
* @throws \Exception * @throws \Exception
@@ -331,6 +333,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
$password = $this->getParam('email_password', true, ''); $password = $this->getParam('email_password', true, '');
$quota = $this->getParam('email_quota', true, $result['quota']); $quota = $this->getParam('email_quota', true, $result['quota']);
$deactivated = $this->getBoolParam('deactivated', true, (strtolower($result['postfix']) == 'n' ? true : false));
// get needed customer info to reduce the email-account-counter by one // get needed customer info to reduce the email-account-counter by one
$customer = $this->getCustomerData(); $customer = $this->getCustomerData();
@@ -372,6 +375,18 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
$quota = 0; $quota = 0;
} }
if ($this->isAdmin()) {
if (($deactivated == true && strtolower($result['postfix']) == 'y') || ($deactivated == false && strtolower($result['postfix']) == 'n')) {
if (! empty($upd_query)) {
$upd_query .= ", ";
}
$upd_query .= "`postfix` = :postfix, `imap` = :imap, `pop3` = :pop3";
$upd_params['postfix'] = $deactivated ? 'N' : 'Y';
$upd_params['imap'] = $deactivated ? '0' : '1';
$upd_params['pop3'] = $deactivated ? '0' : '1';
}
}
// build update query // build update query
if (! empty($upd_query)) { if (! empty($upd_query)) {
$upd_stmt = Database::prepare(" $upd_stmt = Database::prepare("
@@ -389,7 +404,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
$result = $this->apiCall('Emails.get', array( $result = $this->apiCall('Emails.get', array(
'emailaddr' => $result['email_full'] 'emailaddr' => $result['email_full']
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
/** /**
@@ -418,9 +433,9 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
* @param string $emailaddr * @param string $emailaddr
* optional, the email-address to delete the account for * optional, the email-address to delete the account for
* @param int $customerid * @param int $customerid
* optional, admin-only, the customer-id * optional, required when called as admin (if $loginname is not specified)
* @param string $loginname * @param string $loginname
* optional, admin-only, the loginname * optional, required when called as admin (if $customerid is not specified)
* @param bool $delete_userfiles * @param bool $delete_userfiles
* optional, default false * optional, default false
* *
@@ -492,6 +507,6 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
Customers::decreaseUsage($customer['customerid'], 'email_quota_used', '', $quota); Customers::decreaseUsage($customer['customerid'], 'email_quota_used', '', $quota);
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_INFO, "[API] deleted email account for '" . $result['email_full'] . "'"); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_INFO, "[API] deleted email account for '" . $result['email_full'] . "'");
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
} }

View File

@@ -30,9 +30,9 @@ class EmailForwarders extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Re
* @param string $emailaddr * @param string $emailaddr
* optional, the email-address to add the forwarder for * optional, the email-address to add the forwarder for
* @param int $customerid * @param int $customerid
* optional, admin-only, the customer-id * optional, required when called as admin (if $loginname is not specified)
* @param string $loginname * @param string $loginname
* optional, admin-only, the loginname * optional, required when called as admin (if $customerid is not specified)
* @param string $destination * @param string $destination
* email-address to add as forwarder * email-address to add as forwarder
* *
@@ -102,7 +102,7 @@ class EmailForwarders extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Re
$result = $this->apiCall('Emails.get', array( $result = $this->apiCall('Emails.get', array(
'emailaddr' => $result['email_full'] 'emailaddr' => $result['email_full']
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
throw new \Exception("No more resources available", 406); throw new \Exception("No more resources available", 406);
} }
@@ -168,7 +168,7 @@ class EmailForwarders extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Re
]; ];
} }
return $this->response(200, "successfull", [ return $this->response(200, "successful", [
'count' => count($destination), 'count' => count($destination),
'list' => $destination 'list' => $destination
]); ]);
@@ -210,7 +210,7 @@ class EmailForwarders extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Re
$result['destination'] = explode(' ', $result['destination']); $result['destination'] = explode(' ', $result['destination']);
return $this->response(200, "successfull", count($result['destination'])); return $this->response(200, "successful", count($result['destination']));
} }
/** /**
@@ -221,9 +221,9 @@ class EmailForwarders extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Re
* @param string $emailaddr * @param string $emailaddr
* optional, the email-address to delete the forwarder from * optional, the email-address to delete the forwarder from
* @param int $customerid * @param int $customerid
* optional, admin-only, the customer-id * optional, required when called as admin (if $loginname is not specified)
* @param string $loginname * @param string $loginname
* optional, admin-only, the loginname * optional, required when called as admin (if $customerid is not specified)
* @param int $forwarderid * @param int $forwarderid
* id of the forwarder to delete * id of the forwarder to delete
* *
@@ -280,7 +280,7 @@ class EmailForwarders extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Re
$result = $this->apiCall('Emails.get', array( $result = $this->apiCall('Emails.get', array(
'emailaddr' => $result['email_full'] 'emailaddr' => $result['email_full']
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
throw new \Exception("Unknown forwarder id", 404); throw new \Exception("Unknown forwarder id", 404);
} }

View File

@@ -32,9 +32,11 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
* @param boolean $iscatchall * @param boolean $iscatchall
* optional, make this address a catchall address, default: no * optional, make this address a catchall address, default: no
* @param int $customerid * @param int $customerid
* optional, admin-only, the customer-id * optional, required when called as admin (if $loginname is not specified)
* @param string $loginname * @param string $loginname
* optional, admin-only, the loginname * optional, required when called as admin (if $customerid is not specified)
* @param string $description
* optional custom description (currently not used/shown in the frontend), default empty
* *
* @access admin, customer * @access admin, customer
* @throws \Exception * @throws \Exception
@@ -54,6 +56,7 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
// parameters // parameters
$iscatchall = $this->getBoolParam('iscatchall', true, 0); $iscatchall = $this->getBoolParam('iscatchall', true, 0);
$description = $this->getParam('description', true, '');
// validation // validation
if (substr($domain, 0, 4) != 'xn--') { if (substr($domain, 0, 4) != 'xn--') {
@@ -121,14 +124,16 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
`email` = :email, `email` = :email,
`email_full` = :email_full, `email_full` = :email_full,
`iscatchall` = :iscatchall, `iscatchall` = :iscatchall,
`domainid` = :domainid `domainid` = :domainid,
`description` = :description
"); ");
$params = array( $params = array(
"cid" => $customer['customerid'], "cid" => $customer['customerid'],
"email" => $email, "email" => $email,
"email_full" => $email_full, "email_full" => $email_full,
"iscatchall" => $iscatchall, "iscatchall" => $iscatchall,
"domainid" => $domain_check['id'] "domainid" => $domain_check['id'],
"description" => $description
); );
Database::pexecute($stmt, $params, true, true); Database::pexecute($stmt, $params, true, true);
@@ -140,7 +145,7 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
$result = $this->apiCall('Emails.get', array( $result = $this->apiCall('Emails.get', array(
'emailaddr' => $email_full 'emailaddr' => $email_full
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
throw new \Exception("No more resources available", 406); throw new \Exception("No more resources available", 406);
} }
@@ -167,7 +172,7 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
$customer_ids = $this->getAllowedCustomerIds('email'); $customer_ids = $this->getAllowedCustomerIds('email');
$params['idea'] = ($id <= 0 ? $emailaddr : $id); $params['idea'] = ($id <= 0 ? $emailaddr : $id);
$result_stmt = Database::prepare("SELECT v.`id`, v.`email`, v.`email_full`, v.`iscatchall`, v.`destination`, v.`customerid`, v.`popaccountid`, v.`domainid`, u.`quota` $result_stmt = Database::prepare("SELECT v.`id`, v.`email`, v.`email_full`, v.`iscatchall`, v.`destination`, v.`customerid`, v.`popaccountid`, v.`domainid`, v.`description`, u.`quota`, u.`imap`, u.`pop3`, u.`postfix`, u.`mboxsize`
FROM `" . TABLE_MAIL_VIRTUAL . "` v FROM `" . TABLE_MAIL_VIRTUAL . "` v
LEFT JOIN `" . TABLE_MAIL_USERS . "` u ON v.`popaccountid` = u.`id` LEFT JOIN `" . TABLE_MAIL_USERS . "` u ON v.`popaccountid` = u.`id`
WHERE v.`customerid` IN (" . implode(", ", $customer_ids) . ") WHERE v.`customerid` IN (" . implode(", ", $customer_ids) . ")
@@ -176,7 +181,7 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
$result = Database::pexecute_first($result_stmt, $params, true, true); $result = Database::pexecute_first($result_stmt, $params, true, true);
if ($result) { if ($result) {
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] get email address '" . $result['email_full'] . "'"); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] get email address '" . $result['email_full'] . "'");
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
$key = ($id > 0 ? "id #" . $id : "emailaddr '" . $emailaddr . "'"); $key = ($id > 0 ? "id #" . $id : "emailaddr '" . $emailaddr . "'");
throw new \Exception("Email address with " . $key . " could not be found", 404); throw new \Exception("Email address with " . $key . " could not be found", 404);
@@ -190,11 +195,13 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
* @param string $emailaddr * @param string $emailaddr
* optional, the email-address * optional, the email-address
* @param int $customerid * @param int $customerid
* optional, admin-only, the customer-id * optional, required when called as admin (if $loginname is not specified)
* @param string $loginname * @param string $loginname
* optional, admin-only, the loginname * optional, required when called as admin (if $customerid is not specified)
* @param boolean $iscatchall * @param boolean $iscatchall
* optional * optional
* @param string $description
* optional custom description (currently not used/shown in the frontend), default empty
* *
* @access admin, customer * @access admin, customer
* @throws \Exception * @throws \Exception
@@ -227,6 +234,7 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
// parameters // parameters
$iscatchall = $this->getBoolParam('iscatchall', true, $result['iscatchall']); $iscatchall = $this->getBoolParam('iscatchall', true, $result['iscatchall']);
$description = $this->getParam('description', true, $result['description']);
// get needed customer info to reduce the email-address-counter by one // get needed customer info to reduce the email-address-counter by one
$customer = $this->getCustomerData(); $customer = $this->getCustomerData();
@@ -256,12 +264,13 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
$stmt = Database::prepare(" $stmt = Database::prepare("
UPDATE `" . TABLE_MAIL_VIRTUAL . "` UPDATE `" . TABLE_MAIL_VIRTUAL . "`
SET `email` = :email , `iscatchall` = :caflag SET `email` = :email , `iscatchall` = :caflag, `description` = :description
WHERE `customerid`= :cid AND `id`= :id WHERE `customerid`= :cid AND `id`= :id
"); ");
$params = array( $params = array(
"email" => $email, "email" => $email,
"caflag" => $iscatchall, "caflag" => $iscatchall,
"description" => $description,
"cid" => $customer['customerid'], "cid" => $customer['customerid'],
"id" => $id "id" => $id
); );
@@ -271,7 +280,7 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
$result = $this->apiCall('Emails.get', array( $result = $this->apiCall('Emails.get', array(
'emailaddr' => $result['email_full'] 'emailaddr' => $result['email_full']
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
/** /**
@@ -300,7 +309,7 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
$result = array(); $result = array();
$query_fields = array(); $query_fields = array();
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
SELECT m.`id`, m.`domainid`, m.`email`, m.`email_full`, m.`iscatchall`, u.`quota`, m.`destination`, m.`popaccountid`, d.`domain`, u.`mboxsize` SELECT m.`id`, m.`domainid`, m.`email`, m.`email_full`, m.`iscatchall`, m.`destination`, m.`popaccountid`, d.`domain`, u.`quota`, u.`imap`, u.`pop3`, u.`postfix`, u.`mboxsize`
FROM `" . TABLE_MAIL_VIRTUAL . "` m FROM `" . TABLE_MAIL_VIRTUAL . "` m
LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` d ON (m.`domainid` = d.`id`) LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` d ON (m.`domainid` = d.`id`)
LEFT JOIN `" . TABLE_MAIL_USERS . "` u ON (m.`popaccountid` = u.`id`) LEFT JOIN `" . TABLE_MAIL_USERS . "` u ON (m.`popaccountid` = u.`id`)
@@ -310,14 +319,14 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
$result[] = $row; $result[] = $row;
} }
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] list email-addresses"); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] list email-addresses");
return $this->response(200, "successfull", array( return $this->response(200, "successful", array(
'count' => count($result), 'count' => count($result),
'list' => $result 'list' => $result
)); ));
} }
/** /**
* returns the total number of accessable email addresses * returns the total number of accessible email addresses
* *
* @param int $customerid * @param int $customerid
* optional, admin-only, select email addresses of a specific customer by id * optional, admin-only, select email addresses of a specific customer by id
@@ -340,7 +349,7 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
"); ");
$result = Database::pexecute_first($result_stmt, null, true, true); $result = Database::pexecute_first($result_stmt, null, true, true);
if ($result) { if ($result) {
return $this->response(200, "successfull", $result['num_emails']); return $this->response(200, "successful", $result['num_emails']);
} }
} }
@@ -352,9 +361,9 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
* @param string $emailaddr * @param string $emailaddr
* optional, the email-address * optional, the email-address
* @param int $customerid * @param int $customerid
* optional, admin-only, the customer-id * optional, required when called as admin (if $loginname is not specified)
* @param string $loginname * @param string $loginname
* optional, admin-only, the loginname * optional, required when called as admin (if $customerid is not specified)
* @param boolean $delete_userfiles * @param boolean $delete_userfiles
* optional, delete email data from filesystem, default: 0 (false) * optional, delete email data from filesystem, default: 0 (false)
* *
@@ -405,10 +414,6 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
Customers::decreaseUsage($customer['customerid'], 'email_forwarders_used', '', $number_forwarders); Customers::decreaseUsage($customer['customerid'], 'email_forwarders_used', '', $number_forwarders);
Admins::decreaseUsage($customer['customerid'], 'email_forwarders_used', '', $number_forwarders); Admins::decreaseUsage($customer['customerid'], 'email_forwarders_used', '', $number_forwarders);
if ($delete_userfiles) {
\Froxlor\System\Cronjob::inserttask('7', $customer['loginname'], $result['email_full']);
}
// delete address // delete address
$stmt = Database::prepare("DELETE FROM `" . TABLE_MAIL_VIRTUAL . "` WHERE `customerid`= :customerid AND `id`= :id"); $stmt = Database::prepare("DELETE FROM `" . TABLE_MAIL_VIRTUAL . "` WHERE `customerid`= :customerid AND `id`= :id");
Database::pexecute($stmt, array( Database::pexecute($stmt, array(
@@ -418,6 +423,6 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
Customers::decreaseUsage($customer['customerid'], 'emails_used'); Customers::decreaseUsage($customer['customerid'], 'emails_used');
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_INFO, "[API] deleted email address '" . $result['email_full'] . "'"); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_INFO, "[API] deleted email address '" . $result['email_full'] . "'");
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
} }

View File

@@ -70,7 +70,7 @@ class FpmDaemons extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
$fpmdaemons[] = $row; $fpmdaemons[] = $row;
} }
return $this->response(200, "successfull", array( return $this->response(200, "successful", array(
'count' => count($fpmdaemons), 'count' => count($fpmdaemons),
'list' => $fpmdaemons 'list' => $fpmdaemons
)); ));
@@ -79,7 +79,7 @@ class FpmDaemons extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
} }
/** /**
* returns the total number of accessable fpm daemons * returns the total number of accessible fpm daemons
* *
* @access admin * @access admin
* @throws \Exception * @throws \Exception
@@ -93,7 +93,7 @@ class FpmDaemons extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
"); ");
$result = Database::pexecute_first($result_stmt, null, true, true); $result = Database::pexecute_first($result_stmt, null, true, true);
if ($result) { if ($result) {
return $this->response(200, "successfull", $result['num_fpms']); return $this->response(200, "successful", $result['num_fpms']);
} }
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
@@ -121,7 +121,7 @@ class FpmDaemons extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
'id' => $id 'id' => $id
), true, true); ), true, true);
if ($result) { if ($result) {
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
throw new \Exception("fpm-daemon with id #" . $id . " could not be found", 404); throw new \Exception("fpm-daemon with id #" . $id . " could not be found", 404);
} }
@@ -234,7 +234,7 @@ class FpmDaemons extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
$result = $this->apiCall('FpmDaemons.get', array( $result = $this->apiCall('FpmDaemons.get', array(
'id' => $id 'id' => $id
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
} }
@@ -356,7 +356,7 @@ class FpmDaemons extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
$result = $this->apiCall('FpmDaemons.get', array( $result = $this->apiCall('FpmDaemons.get', array(
'id' => $id 'id' => $id
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
} }
@@ -402,7 +402,7 @@ class FpmDaemons extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
\Froxlor\System\Cronjob::inserttask('1'); \Froxlor\System\Cronjob::inserttask('1');
$this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "[API] fpm-daemon setting '" . $result['description'] . "' has been deleted by '" . $this->getUserDetail('loginname') . "'"); $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "[API] fpm-daemon setting '" . $result['description'] . "' has been deleted by '" . $this->getUserDetail('loginname') . "'");
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
} }

View File

@@ -74,7 +74,7 @@ class Froxlor extends \Froxlor\Api\ApiCommand
// zum update schritt #1 -> download // zum update schritt #1 -> download
if ($isnewerversion == 1) { if ($isnewerversion == 1) {
$text = 'There is a newer version available: "' . $_version . '" (Your current version is: ' . $this->version . ')'; $text = 'There is a newer version available: "' . $_version . '" (Your current version is: ' . $this->version . ')';
return $this->response(200, "successfull", array( return $this->response(200, "successful", array(
'isnewerversion' => $isnewerversion, 'isnewerversion' => $isnewerversion,
'version' => $_version, 'version' => $_version,
'message' => $text, 'message' => $text,
@@ -83,7 +83,7 @@ class Froxlor extends \Froxlor\Api\ApiCommand
)); ));
} elseif ($isnewerversion == 0) { } elseif ($isnewerversion == 0) {
// all good // all good
return $this->response(200, "successfull", array( return $this->response(200, "successful", array(
'isnewerversion' => $isnewerversion, 'isnewerversion' => $isnewerversion,
'version' => $version_label, 'version' => $version_label,
'message' => "", 'message' => "",
@@ -95,7 +95,7 @@ class Froxlor extends \Froxlor\Api\ApiCommand
} }
} }
} }
return $this->response(300, "successfull", array( return $this->response(300, "successful", array(
'isnewerversion' => 0, 'isnewerversion' => 0,
'version' => $this->version . $this->branding, 'version' => $this->version . $this->branding,
'message' => 'Version-check not available due to missing php-curl extension', 'message' => 'Version-check not available due to missing php-curl extension',
@@ -129,7 +129,7 @@ class Froxlor extends \Froxlor\Api\ApiCommand
\Froxlor\System\Cronjob::inserttask('4'); \Froxlor\System\Cronjob::inserttask('4');
// cron.d file // cron.d file
\Froxlor\System\Cronjob::inserttask('99'); \Froxlor\System\Cronjob::inserttask('99');
return $this->response(200, "successfull", true); return $this->response(200, "successful", true);
} catch (\Exception $e) { } catch (\Exception $e) {
throw new \Exception($e->getMessage(), 406); throw new \Exception($e->getMessage(), 406);
} }
@@ -149,7 +149,7 @@ class Froxlor extends \Froxlor\Api\ApiCommand
if ($this->isAdmin() && $this->getUserDetail('change_serversettings')) { if ($this->isAdmin() && $this->getUserDetail('change_serversettings')) {
$this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "User " . $this->getUserDetail('loginname') . " exported settings"); $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "User " . $this->getUserDetail('loginname') . " exported settings");
$json_export = \Froxlor\SImExporter::export(); $json_export = \Froxlor\SImExporter::export();
return $this->response(200, "successfull", $json_export); return $this->response(200, "successful", $json_export);
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
} }
@@ -175,7 +175,7 @@ class Froxlor extends \Froxlor\Api\ApiCommand
'value' => $row['value'] 'value' => $row['value']
); );
} }
return $this->response(200, "successfull", array( return $this->response(200, "successful", array(
'count' => count($result), 'count' => count($result),
'list' => $result 'list' => $result
)); ));
@@ -197,7 +197,7 @@ class Froxlor extends \Froxlor\Api\ApiCommand
{ {
if ($this->isAdmin() && $this->getUserDetail('change_serversettings')) { if ($this->isAdmin() && $this->getUserDetail('change_serversettings')) {
$setting = $this->getParam('key'); $setting = $this->getParam('key');
return $this->response(200, "successfull", Settings::Get($setting)); return $this->response(200, "successful", Settings::Get($setting));
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
} }
@@ -227,7 +227,7 @@ class Froxlor extends \Froxlor\Api\ApiCommand
throw new \Exception("Setting '" . $setting . "' could not be found"); throw new \Exception("Setting '" . $setting . "' could not be found");
} }
$this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "[API] Changing setting '" . $setting . "' from '" . $oldvalue . "' to '" . $value . "'"); $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "[API] Changing setting '" . $setting . "' from '" . $oldvalue . "' to '" . $value . "'");
return $this->response(200, "successfull", Settings::Set($setting, $value, true)); return $this->response(200, "successful", Settings::Set($setting, $value, true));
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
} }
@@ -240,7 +240,7 @@ class Froxlor extends \Froxlor\Api\ApiCommand
*/ */
public function generatePassword() public function generatePassword()
{ {
return $this->response(200, "successfull", \Froxlor\System\Crypt::generatePassword()); return $this->response(200, "successful", \Froxlor\System\Crypt::generatePassword());
} }
/** /**
@@ -256,7 +256,7 @@ class Froxlor extends \Froxlor\Api\ApiCommand
$integrity = new \Froxlor\Database\IntegrityCheck(); $integrity = new \Froxlor\Database\IntegrityCheck();
$result = $integrity->checkAll(); $result = $integrity->checkAll();
if ($result) { if ($result) {
return $this->response(200, "successfull", "OK"); return $this->response(200, "successful", "OK");
} }
throw new \Exception("Some checks failed.", 406); throw new \Exception("Some checks failed.", 406);
} }
@@ -333,7 +333,7 @@ class Froxlor extends \Froxlor\Api\ApiCommand
} }
// return the list // return the list
return $this->response(200, "successfull", $functions); return $this->response(200, "successful", $functions);
} }
/** /**

View File

@@ -40,7 +40,9 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit
* @param string $ftp_domain * @param string $ftp_domain
* optional if customer.ftpatdomain is allowed, specify a domain (customer must be owner) * optional if customer.ftpatdomain is allowed, specify a domain (customer must be owner)
* @param int $customerid * @param int $customerid
* required when called as admin, not needed when called as customer * optional, required when called as admin (if $loginname is not specified)
* @param string $loginname
* optional, required when called as admin (if $customerid is not specified)
* @param array $additional_members * @param array $additional_members
* optional whether to add additional usernames to the group * optional whether to add additional usernames to the group
* @param bool $is_defaultuser * @param bool $is_defaultuser
@@ -60,7 +62,7 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit
if (($this->getUserDetail('ftps_used') < $this->getUserDetail('ftps') || $this->getUserDetail('ftps') == '-1') || $this->isAdmin() && $is_defaultuser == 1) { if (($this->getUserDetail('ftps_used') < $this->getUserDetail('ftps') || $this->getUserDetail('ftps') == '-1') || $this->isAdmin() && $is_defaultuser == 1) {
// required paramters // required parameters
$path = $this->getParam('path'); $path = $this->getParam('path');
$password = $this->getParam('ftp_password'); $password = $this->getParam('ftp_password');
@@ -180,6 +182,17 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit
), true, true); ), true, true);
} }
// create quotatallies entry if it not exists, refs #885
if ($result_stmt->rowCount() == 0) {
$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', '0', '0', '0', '0', '0', '0')
");
Database::pexecute($stmt, array(
"name" => $username
), true, true);
}
$group_upd_stmt = Database::prepare(" $group_upd_stmt = Database::prepare("
UPDATE `" . TABLE_FTP_GROUPS . "` UPDATE `" . TABLE_FTP_GROUPS . "`
SET `members` = CONCAT_WS(',',`members`, :username) SET `members` = CONCAT_WS(',',`members`, :username)
@@ -232,7 +245,7 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit
'COMPANY' => $customer['company'], 'COMPANY' => $customer['company'],
'CUSTOMER_NO' => $customer['customernumber'], 'CUSTOMER_NO' => $customer['customernumber'],
'USR_NAME' => $username, 'USR_NAME' => $username,
'USR_PASS' => $password, 'USR_PASS' => htmlentities(htmlentities($password)),
'USR_PATH' => \Froxlor\FileDir::makeCorrectDir(str_replace($customer['documentroot'], "/", $path)) 'USR_PATH' => \Froxlor\FileDir::makeCorrectDir(str_replace($customer['documentroot'], "/", $path))
); );
// get template for mail subject // get template for mail subject
@@ -268,7 +281,7 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit
$result = $this->apiCall('Ftps.get', array( $result = $this->apiCall('Ftps.get', array(
'username' => $username 'username' => $username
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
} }
throw new \Exception("No more resources available", 406); throw new \Exception("No more resources available", 406);
@@ -329,7 +342,7 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit
$result = Database::pexecute_first($result_stmt, $params, true, true); $result = Database::pexecute_first($result_stmt, $params, true, true);
if ($result) { if ($result) {
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] get ftp-user '" . $result['username'] . "'"); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] get ftp-user '" . $result['username'] . "'");
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
$key = ($id > 0 ? "id #" . $id : "username '" . $username . "'"); $key = ($id > 0 ? "id #" . $id : "username '" . $username . "'");
throw new \Exception("FTP user with " . $key . " could not be found", 404); throw new \Exception("FTP user with " . $key . " could not be found", 404);
@@ -339,11 +352,11 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit
* update a given ftp-user by id or username * update a given ftp-user by id or username
* *
* @param int $id * @param int $id
* optional, the customer-id * optional, the ftp-user-id
* @param string $username * @param string $username
* optional, the username * optional, the username
* @param string $ftp_password * @param string $ftp_password
* password for the created database and database-user * optional, update password if specified
* @param string $path * @param string $path
* destination path relative to the customers-homedir * destination path relative to the customers-homedir
* @param string $ftp_description * @param string $ftp_description
@@ -351,7 +364,9 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit
* @param string $shell * @param string $shell
* optional, default /bin/false (not changeable when deactivated) * optional, default /bin/false (not changeable when deactivated)
* @param int $customerid * @param int $customerid
* required when called as admin, not needed when called as customer * optional, required when called as admin (if $loginname is not specified)
* @param string $loginname
* optional, required when called as admin (if $customerid is not specified)
* *
* @access admin, customer * @access admin, customer
* @throws \Exception * @throws \Exception
@@ -454,7 +469,7 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit
'username' => $result['username'] 'username' => $result['username']
)); ));
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] updated ftp-user '" . $result['username'] . "'"); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] updated ftp-user '" . $result['username'] . "'");
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
/** /**
@@ -490,14 +505,14 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit
$result[] = $row; $result[] = $row;
} }
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] list ftp-users"); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] list ftp-users");
return $this->response(200, "successfull", array( return $this->response(200, "successful", array(
'count' => count($result), 'count' => count($result),
'list' => $result 'list' => $result
)); ));
} }
/** /**
* returns the total number of accessable ftp accounts * returns the total number of accessible ftp accounts
* *
* @param int $customerid * @param int $customerid
* optional, admin-only, select ftp-users of a specific customer by id * optional, admin-only, select ftp-users of a specific customer by id
@@ -518,7 +533,7 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit
"); ");
$result = Database::pexecute_first($result_stmt, null, true, true); $result = Database::pexecute_first($result_stmt, null, true, true);
if ($result) { if ($result) {
return $this->response(200, "successfull", $result['num_ftps']); return $this->response(200, "successful", $result['num_ftps']);
} }
} }
@@ -626,6 +641,6 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit
Customers::decreaseUsage($customer_data['customerid'], 'ftps_used', $resetaccnumber); Customers::decreaseUsage($customer_data['customerid'], 'ftps_used', $resetaccnumber);
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_WARNING, "[API] deleted ftp-user '" . $result['username'] . "'"); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_WARNING, "[API] deleted ftp-user '" . $result['username'] . "'");
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
} }

View File

@@ -57,7 +57,7 @@ class HostingPlans extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou
while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) { while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) {
$result[] = $row; $result[] = $row;
} }
return $this->response(200, "successfull", array( return $this->response(200, "successful", array(
'count' => count($result), 'count' => count($result),
'list' => $result 'list' => $result
)); ));
@@ -66,7 +66,7 @@ class HostingPlans extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou
} }
/** /**
* returns the total number of accessable hosting plans * returns the total number of accessible hosting plans
* *
* @access admin * @access admin
* @throws \Exception * @throws \Exception
@@ -85,7 +85,7 @@ class HostingPlans extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou
} }
$result = Database::pexecute_first($result_stmt, $params, true, true); $result = Database::pexecute_first($result_stmt, $params, true, true);
if ($result) { if ($result) {
return $this->response(200, "successfull", $result['num_plans']); return $this->response(200, "successful", $result['num_plans']);
} }
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
@@ -120,7 +120,7 @@ class HostingPlans extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou
$result = Database::pexecute_first($result_stmt, $params, true, true); $result = Database::pexecute_first($result_stmt, $params, true, true);
if ($result) { if ($result) {
$this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] get hosting-plan '" . $result['name'] . "'"); $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] get hosting-plan '" . $result['name'] . "'");
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
$key = ($id > 0 ? "id #" . $id : "planname '" . $planname . "'"); $key = ($id > 0 ? "id #" . $id : "planname '" . $planname . "'");
throw new \Exception("Hosting-plan with " . $key . " could not be found", 404); throw new \Exception("Hosting-plan with " . $key . " could not be found", 404);
@@ -182,9 +182,9 @@ class HostingPlans extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou
* @param bool $perlenabled * @param bool $perlenabled
* optional, whether to allow usage of Perl/CGI, default 0 (false) * optional, whether to allow usage of Perl/CGI, default 0 (false)
* @param bool $dnsenabled * @param bool $dnsenabled
* optional, ether to allow usage of the DNS editor (requires activated nameserver in settings), default 0 (false) * optional, whether to allow usage of the DNS editor (requires activated nameserver in settings), default 0 (false)
* @param bool $logviewenabled * @param bool $logviewenabled
* optional, ether to allow acccess to webserver access/error-logs, default 0 (false) * optional, whether to allow access to webserver access/error-logs, default 0 (false)
* *
* @access admin * @access admin
* @throws \Exception * @throws \Exception
@@ -246,7 +246,7 @@ class HostingPlans extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou
$result = $this->apiCall('HostingPlans.get', array( $result = $this->apiCall('HostingPlans.get', array(
'planname' => $name 'planname' => $name
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
} }
@@ -309,9 +309,9 @@ class HostingPlans extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou
* @param bool $perlenabled * @param bool $perlenabled
* optional, whether to allow usage of Perl/CGI, default 0 (false) * optional, whether to allow usage of Perl/CGI, default 0 (false)
* @param bool $dnsenabled * @param bool $dnsenabled
* optional, ether to allow usage of the DNS editor (requires activated nameserver in settings), default 0 (false) * optional, either to allow usage of the DNS editor (requires activated nameserver in settings), default 0 (false)
* @param bool $logviewenabled * @param bool $logviewenabled
* optional, ether to allow acccess to webserver access/error-logs, default 0 (false) * optional, either to allow access to webserver access/error-logs, default 0 (false)
* *
* @access admin * @access admin
* @throws \Exception * @throws \Exception
@@ -393,7 +393,7 @@ class HostingPlans extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou
); );
Database::pexecute($upd_stmt, $update_data, true, true); Database::pexecute($upd_stmt, $update_data, true, true);
$this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "[API] updated hosting-plan '" . $result['name'] . "'"); $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "[API] updated hosting-plan '" . $result['name'] . "'");
return $this->response(200, "successfull", $update_data); return $this->response(200, "successful", $update_data);
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
} }
@@ -431,7 +431,7 @@ class HostingPlans extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou
'id' => $id 'id' => $id
), true, true); ), true, true);
$this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "[API] deleted hosting-plan '" . $result['name'] . "'"); $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "[API] deleted hosting-plan '" . $result['name'] . "'");
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
} }

View File

@@ -51,12 +51,12 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
$query_fields = array(); $query_fields = array();
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
SELECT * FROM `" . TABLE_PANEL_IPSANDPORTS . "` " . $ip_where . $this->getSearchWhere($query_fields, $append_where) . $this->getOrderBy() . $this->getLimit()); SELECT * FROM `" . TABLE_PANEL_IPSANDPORTS . "` " . $ip_where . $this->getSearchWhere($query_fields, $append_where) . $this->getOrderBy() . $this->getLimit());
Database::pexecute($result_stmt, null, true, true); Database::pexecute($result_stmt, $query_fields, true, true);
$result = array(); $result = array();
while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) { while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) {
$result[] = $row; $result[] = $row;
} }
return $this->response(200, "successfull", array( return $this->response(200, "successful", array(
'count' => count($result), 'count' => count($result),
'list' => $result 'list' => $result
)); ));
@@ -65,7 +65,7 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
} }
/** /**
* returns the total number of accessable ip/port entries * returns the total number of accessible ip/port entries
* *
* @access admin * @access admin
* @throws \Exception * @throws \Exception
@@ -82,7 +82,7 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
SELECT COUNT(*) as num_ips FROM `" . TABLE_PANEL_IPSANDPORTS . "` " . $ip_where); SELECT COUNT(*) as num_ips FROM `" . TABLE_PANEL_IPSANDPORTS . "` " . $ip_where);
$result = Database::pexecute_first($result_stmt, null, true, true); $result = Database::pexecute_first($result_stmt, null, true, true);
if ($result) { if ($result) {
return $this->response(200, "successfull", $result['num_ips']); return $this->response(200, "successful", $result['num_ips']);
} }
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
@@ -116,7 +116,7 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
), true, true); ), true, true);
if ($result) { if ($result) {
$this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] get ip " . $result['ip'] . " " . $result['port']); $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] get ip " . $result['ip'] . " " . $result['port']);
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
throw new \Exception("IP/port with id #" . $id . " could not be found", 404); throw new \Exception("IP/port with id #" . $id . " could not be found", 404);
} }
@@ -171,17 +171,17 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
if ($this->isAdmin() && $this->getUserDetail('change_serversettings')) { if ($this->isAdmin() && $this->getUserDetail('change_serversettings')) {
$ip = \Froxlor\Validate\Validate::validate_ip2($this->getParam('ip'), false, 'invalidip', false, true, false, false, true); $ip = \Froxlor\Validate\Validate::validate_ip2($this->getParam('ip'), false, 'invalidip', false, true, false, false, true);
$port = \Froxlor\Validate\Validate::validate($this->getParam('port', true, 80), '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( $port = \Froxlor\Validate\Validate::validate($this->getParam('port', true, 80), 'port', \Froxlor\Validate\Validate::REGEX_PORT, array(
'stringisempty', 'stringisempty',
'myport' 'myport'
), array(), true); ), array(), true);
$listen_statement = ! empty($this->getBoolParam('listen_statement', true, 0)) ? 1 : 0; $listen_statement = ! empty($this->getBoolParam('listen_statement', true, 0)) ? 1 : 0;
$namevirtualhost_statement = ! empty($this->getBoolParam('namevirtualhost_statement', true, 0)) ? 1 : 0; $namevirtualhost_statement = ! empty($this->getBoolParam('namevirtualhost_statement', true, 0)) ? 1 : 0;
$vhostcontainer = ! empty($this->getBoolParam('vhostcontainer', true, 0)) ? 1 : 0; $vhostcontainer = ! empty($this->getBoolParam('vhostcontainer', true, 0)) ? 1 : 0;
$specialsettings = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $this->getParam('specialsettings', true, '')), 'specialsettings', '/^[^\0]*$/', '', array(), true); $specialsettings = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $this->getParam('specialsettings', true, '')), 'specialsettings', \Froxlor\Validate\Validate::REGEX_CONF_TEXT, '', array(), true);
$vhostcontainer_servername_statement = ! empty($this->getBoolParam('vhostcontainer_servername_statement', true, 1)) ? 1 : 0; $vhostcontainer_servername_statement = ! empty($this->getBoolParam('vhostcontainer_servername_statement', true, 1)) ? 1 : 0;
$default_vhostconf_domain = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $this->getParam('default_vhostconf_domain', true, '')), 'default_vhostconf_domain', '/^[^\0]*$/', '', array(), true); $default_vhostconf_domain = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $this->getParam('default_vhostconf_domain', true, '')), 'default_vhostconf_domain', \Froxlor\Validate\Validate::REGEX_CONF_TEXT, '', array(), true);
$docroot = \Froxlor\Validate\Validate::validate($this->getParam('docroot', true, ''), 'docroot', '', '', array(), true); $docroot = \Froxlor\Validate\Validate::validate($this->getParam('docroot', true, ''), 'docroot', \Froxlor\Validate\Validate::REGEX_DIR, '', array(), true);
if ((int) Settings::Get('system.use_ssl') == 1) { if ((int) Settings::Get('system.use_ssl') == 1) {
$ssl = ! empty($this->getBoolParam('ssl', true, 0)) ? intval($this->getBoolParam('ssl', true, 0)) : 0; $ssl = ! empty($this->getBoolParam('ssl', true, 0)) ? intval($this->getBoolParam('ssl', true, 0)) : 0;
@@ -189,9 +189,9 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
$ssl_key_file = \Froxlor\Validate\Validate::validate($this->getParam('ssl_key_file', $ssl, ''), 'ssl_key_file', '', '', array(), true); $ssl_key_file = \Froxlor\Validate\Validate::validate($this->getParam('ssl_key_file', $ssl, ''), 'ssl_key_file', '', '', array(), true);
$ssl_ca_file = \Froxlor\Validate\Validate::validate($this->getParam('ssl_ca_file', true, ''), 'ssl_ca_file', '', '', array(), true); $ssl_ca_file = \Froxlor\Validate\Validate::validate($this->getParam('ssl_ca_file', true, ''), 'ssl_ca_file', '', '', array(), true);
$ssl_cert_chainfile = \Froxlor\Validate\Validate::validate($this->getParam('ssl_cert_chainfile', true, ''), 'ssl_cert_chainfile', '', '', array(), true); $ssl_cert_chainfile = \Froxlor\Validate\Validate::validate($this->getParam('ssl_cert_chainfile', true, ''), 'ssl_cert_chainfile', '', '', array(), true);
$ssl_specialsettings = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $this->getParam('ssl_specialsettings', true, '')), 'ssl_specialsettings', '/^[^\0]*$/', '', array(), true); $ssl_specialsettings = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $this->getParam('ssl_specialsettings', true, '')), 'ssl_specialsettings', \Froxlor\Validate\Validate::REGEX_CONF_TEXT, '', array(), true);
$include_specialsettings = ! empty($this->getBoolParam('include_specialsettings', true, 0)) ? 1 : 0; $include_specialsettings = ! empty($this->getBoolParam('include_specialsettings', true, 0)) ? 1 : 0;
$ssl_default_vhostconf_domain = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $this->getParam('ssl_default_vhostconf_domain', true, '')), 'ssl_default_vhostconf_domain', '/^[^\0]*$/', '', array(), true); $ssl_default_vhostconf_domain = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $this->getParam('ssl_default_vhostconf_domain', true, '')), 'ssl_default_vhostconf_domain', \Froxlor\Validate\Validate::REGEX_CONF_TEXT, '', array(), true);
$include_default_vhostconf_domain = ! empty($this->getBoolParam('include_default_vhostconf_domain', true, 0)) ? 1 : 0; $include_default_vhostconf_domain = ! empty($this->getBoolParam('include_default_vhostconf_domain', true, 0)) ? 1 : 0;
} else { } else {
$ssl = 0; $ssl = 0;
@@ -247,6 +247,9 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
$docroot = ''; $docroot = '';
} }
// always use compressed ipv6 format
$ip = inet_ntop(inet_pton($ip));
$result_checkfordouble_stmt = Database::prepare(" $result_checkfordouble_stmt = Database::prepare("
SELECT `id` FROM `" . TABLE_PANEL_IPSANDPORTS . "` SELECT `id` FROM `" . TABLE_PANEL_IPSANDPORTS . "`
WHERE `ip` = :ip AND `port` = :port"); WHERE `ip` = :ip AND `port` = :port");
@@ -307,7 +310,7 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
$result = $this->apiCall('IpsAndPorts.get', array( $result = $this->apiCall('IpsAndPorts.get', array(
'id' => $ins_data['id'] 'id' => $ins_data['id']
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
} }
@@ -368,17 +371,17 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
)); ));
$ip = \Froxlor\Validate\Validate::validate_ip2($this->getParam('ip', true, $result['ip']), false, 'invalidip', false, true, false, false, true); $ip = \Froxlor\Validate\Validate::validate_ip2($this->getParam('ip', true, $result['ip']), false, 'invalidip', false, true, false, false, true);
$port = \Froxlor\Validate\Validate::validate($this->getParam('port', true, $result['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( $port = \Froxlor\Validate\Validate::validate($this->getParam('port', true, $result['port']), 'port', \Froxlor\Validate\Validate::REGEX_PORT, array(
'stringisempty', 'stringisempty',
'myport' 'myport'
), array(), true); ), array(), true);
$listen_statement = $this->getBoolParam('listen_statement', true, $result['listen_statement']); $listen_statement = $this->getBoolParam('listen_statement', true, $result['listen_statement']);
$namevirtualhost_statement = $this->getBoolParam('namevirtualhost_statement', true, $result['namevirtualhost_statement']); $namevirtualhost_statement = $this->getBoolParam('namevirtualhost_statement', true, $result['namevirtualhost_statement']);
$vhostcontainer = $this->getBoolParam('vhostcontainer', true, $result['vhostcontainer']); $vhostcontainer = $this->getBoolParam('vhostcontainer', true, $result['vhostcontainer']);
$specialsettings = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $this->getParam('specialsettings', true, $result['specialsettings'])), 'specialsettings', '/^[^\0]*$/', '', array(), true); $specialsettings = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $this->getParam('specialsettings', true, $result['specialsettings'])), 'specialsettings', \Froxlor\Validate\Validate::REGEX_CONF_TEXT, '', array(), true);
$vhostcontainer_servername_statement = $this->getParam('vhostcontainer_servername_statement', true, $result['vhostcontainer_servername_statement']); $vhostcontainer_servername_statement = $this->getParam('vhostcontainer_servername_statement', true, $result['vhostcontainer_servername_statement']);
$default_vhostconf_domain = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $this->getParam('default_vhostconf_domain', true, $result['default_vhostconf_domain'])), 'default_vhostconf_domain', '/^[^\0]*$/', '', array(), true); $default_vhostconf_domain = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $this->getParam('default_vhostconf_domain', true, $result['default_vhostconf_domain'])), 'default_vhostconf_domain', \Froxlor\Validate\Validate::REGEX_CONF_TEXT, '', array(), true);
$docroot = \Froxlor\Validate\Validate::validate($this->getParam('docroot', true, $result['docroot']), 'docroot', '', '', array(), true); $docroot = \Froxlor\Validate\Validate::validate($this->getParam('docroot', true, $result['docroot']), 'docroot', \Froxlor\Validate\Validate::REGEX_DIR, '', array(), true);
if ((int) Settings::Get('system.use_ssl') == 1) { if ((int) Settings::Get('system.use_ssl') == 1) {
$ssl = $this->getBoolParam('ssl', true, $result['ssl']); $ssl = $this->getBoolParam('ssl', true, $result['ssl']);
@@ -386,9 +389,9 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
$ssl_key_file = \Froxlor\Validate\Validate::validate($this->getParam('ssl_key_file', $ssl, $result['ssl_key_file']), 'ssl_key_file', '', '', array(), true); $ssl_key_file = \Froxlor\Validate\Validate::validate($this->getParam('ssl_key_file', $ssl, $result['ssl_key_file']), 'ssl_key_file', '', '', array(), true);
$ssl_ca_file = \Froxlor\Validate\Validate::validate($this->getParam('ssl_ca_file', true, $result['ssl_ca_file']), 'ssl_ca_file', '', '', array(), true); $ssl_ca_file = \Froxlor\Validate\Validate::validate($this->getParam('ssl_ca_file', true, $result['ssl_ca_file']), 'ssl_ca_file', '', '', array(), true);
$ssl_cert_chainfile = \Froxlor\Validate\Validate::validate($this->getParam('ssl_cert_chainfile', true, $result['ssl_cert_chainfile']), 'ssl_cert_chainfile', '', '', array(), true); $ssl_cert_chainfile = \Froxlor\Validate\Validate::validate($this->getParam('ssl_cert_chainfile', true, $result['ssl_cert_chainfile']), 'ssl_cert_chainfile', '', '', array(), true);
$ssl_specialsettings = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $this->getParam('ssl_specialsettings', true, $result['ssl_specialsettings'])), 'ssl_specialsettings', '/^[^\0]*$/', '', array(), true); $ssl_specialsettings = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $this->getParam('ssl_specialsettings', true, $result['ssl_specialsettings'])), 'ssl_specialsettings', \Froxlor\Validate\Validate::REGEX_CONF_TEXT, '', array(), true);
$include_specialsettings = $this->getBoolParam('include_specialsettings', true, $result['include_specialsettings']); $include_specialsettings = $this->getBoolParam('include_specialsettings', true, $result['include_specialsettings']);
$ssl_default_vhostconf_domain = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $this->getParam('ssl_default_vhostconf_domain', true, $result['ssl_default_vhostconf_domain'])), 'ssl_default_vhostconf_domain', '/^[^\0]*$/', '', array(), true); $ssl_default_vhostconf_domain = \Froxlor\Validate\Validate::validate(str_replace("\r\n", "\n", $this->getParam('ssl_default_vhostconf_domain', true, $result['ssl_default_vhostconf_domain'])), 'ssl_default_vhostconf_domain', \Froxlor\Validate\Validate::REGEX_CONF_TEXT, '', array(), true);
$include_default_vhostconf_domain = $this->getBoolParam('include_default_vhostconf_domain', true, $result['include_default_vhostconf_domain']); $include_default_vhostconf_domain = $this->getBoolParam('include_default_vhostconf_domain', true, $result['include_default_vhostconf_domain']);
} else { } else {
$ssl = 0; $ssl = 0;
@@ -462,6 +465,9 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
$docroot = ''; $docroot = '';
} }
// always use compressed ipv6 format
$ip = inet_ntop(inet_pton($ip));
if ($result['ip'] != $ip && $result['ip'] == Settings::Get('system.ipaddress') && $result_sameipotherport == false) { if ($result['ip'] != $ip && $result['ip'] == Settings::Get('system.ipaddress') && $result_sameipotherport == false) {
\Froxlor\UI\Response::standard_error('cantchangesystemip', '', true); \Froxlor\UI\Response::standard_error('cantchangesystemip', '', true);
} elseif ($result_checkfordouble && $result_checkfordouble['id'] != '' && $result_checkfordouble['id'] != $id) { } elseif ($result_checkfordouble && $result_checkfordouble['id'] != '' && $result_checkfordouble['id'] != $id) {
@@ -514,7 +520,7 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
$result = $this->apiCall('IpsAndPorts.get', array( $result = $this->apiCall('IpsAndPorts.get', array(
'id' => $result['id'] 'id' => $result['id']
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
@@ -583,7 +589,7 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
\Froxlor\System\Cronjob::inserttask('4'); \Froxlor\System\Cronjob::inserttask('4');
$this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "[API] deleted IP/port '" . $result['ip'] . ":" . $result['port'] . "'"); $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, "[API] deleted IP/port '" . $result['ip'] . ":" . $result['port'] . "'");
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} else { } else {
\Froxlor\UI\Response::standard_error('cantdeletesystemip', '', true); \Froxlor\UI\Response::standard_error('cantdeletesystemip', '', true);
} }

View File

@@ -31,12 +31,14 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
* optional, default is 0 * optional, default is 0
* @param string $description * @param string $description
* optional, description for database * optional, description for database
* @param string $custom_suffix
* optional, name for database
* @param bool $sendinfomail * @param bool $sendinfomail
* optional, send created resource-information to customer, default: false * optional, send created resource-information to customer, default: false
* @param int $customerid * @param int $customerid
* optional, admin-only, the customer-id * optional, required when called as admin (if $loginname is not specified)
* @param string $loginname * @param string $loginname
* optional, admin-only, the loginname * optional, required when called as admin (if $customerid is not specified)
* *
* @access admin, customer * @access admin, customer
* @throws \Exception * @throws \Exception
@@ -44,12 +46,13 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
*/ */
public function add() public function add()
{ {
// required paramters // required parameters
$password = $this->getParam('mysql_password'); $password = $this->getParam('mysql_password');
// parameters // parameters
$dbserver = $this->getParam('mysql_server', true, 0); $dbserver = $this->getParam('mysql_server', true, 0);
$databasedescription = $this->getParam('description', true, ''); $databasedescription = $this->getParam('description', true, '');
$databasename = $this->getParam('custom_suffix', true, '');
$sendinfomail = $this->getBoolParam('sendinfomail', true, 0); $sendinfomail = $this->getBoolParam('sendinfomail', true, 0);
// get needed customer info to reduce the mysql-usage-counter by one // get needed customer info to reduce the mysql-usage-counter by one
$customer = $this->getCustomerData('mysqls'); $customer = $this->getCustomerData('mysqls');
@@ -58,6 +61,7 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
$password = \Froxlor\Validate\Validate::validate($password, 'password', '', '', array(), true); $password = \Froxlor\Validate\Validate::validate($password, 'password', '', '', array(), true);
$password = \Froxlor\System\Crypt::validatePassword($password, true); $password = \Froxlor\System\Crypt::validatePassword($password, true);
$databasedescription = \Froxlor\Validate\Validate::validate(trim($databasedescription), 'description', '', '', array(), true); $databasedescription = \Froxlor\Validate\Validate::validate(trim($databasedescription), 'description', '', '', array(), true);
$databasename = \Froxlor\Validate\Validate::validate(trim($databasename), 'database_name', '', '', array(), true);
// validate whether the dbserver exists // validate whether the dbserver exists
$dbserver = \Froxlor\Validate\Validate::validate($dbserver, html_entity_decode($this->lng['mysql']['mysql_server']), '', '', 0, true); $dbserver = \Froxlor\Validate\Validate::validate($dbserver, html_entity_decode($this->lng['mysql']['mysql_server']), '', '', 0, true);
@@ -79,7 +83,12 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
); );
// create database, user, set permissions, etc.pp. // create database, user, set permissions, etc.pp.
$dbm = new \Froxlor\Database\DbManager($this->logger()); $dbm = new \Froxlor\Database\DbManager($this->logger());
if(strtoupper(Settings::Get('customer.mysqlprefix')) == 'DBNAME' && !empty($databasename)) {
$username = $dbm->createDatabase($newdb_params['loginname'].'_'.$databasename, $password);
} else {
$username = $dbm->createDatabase($newdb_params['loginname'], $password, $newdb_params['mysql_lastaccountnumber']); $username = $dbm->createDatabase($newdb_params['loginname'], $password, $newdb_params['mysql_lastaccountnumber']);
}
// we've checked against the password in dbm->createDatabase // we've checked against the password in dbm->createDatabase
if ($username == false) { if ($username == false) {
@@ -130,7 +139,7 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
'COMPANY' => $userinfo['company'], 'COMPANY' => $userinfo['company'],
'CUSTOMER_NO' => $userinfo['customernumber'], 'CUSTOMER_NO' => $userinfo['customernumber'],
'DB_NAME' => $username, 'DB_NAME' => $username,
'DB_PASS' => $password, 'DB_PASS' => htmlentities(htmlentities($password)),
'DB_DESC' => $databasedescription, 'DB_DESC' => $databasedescription,
'DB_SRV' => $sql_root['host'], 'DB_SRV' => $sql_root['host'],
'PMA_URI' => $pma 'PMA_URI' => $pma
@@ -169,7 +178,7 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
$result = $this->apiCall('Mysqls.get', array( $result = $this->apiCall('Mysqls.get', array(
'dbname' => $username 'dbname' => $username
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
/** /**
@@ -258,7 +267,7 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
Database::needRoot(false); Database::needRoot(false);
$result['size'] = $mbdata['MB'] ?? 0; $result['size'] = $mbdata['MB'] ?? 0;
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] get database '" . $result['databasename'] . "'"); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] get database '" . $result['databasename'] . "'");
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
$key = ($id > 0 ? "id #" . $id : "dbname '" . $dbname . "'"); $key = ($id > 0 ? "id #" . $id : "dbname '" . $dbname . "'");
throw new \Exception("MySQL database with " . $key . " could not be found", 404); throw new \Exception("MySQL database with " . $key . " could not be found", 404);
@@ -278,9 +287,9 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
* @param string $description * @param string $description
* optional, description for database * optional, description for database
* @param int $customerid * @param int $customerid
* optional, admin-only, the customer-id * optional, required when called as admin (if $loginname is not specified)
* @param string $loginname * @param string $loginname
* optional, admin-only, the loginname * optional, required when called as admin (if $customerid is not specified)
* *
* @access admin, customer * @access admin, customer
* @throws \Exception * @throws \Exception
@@ -305,9 +314,9 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
)); ));
$id = $result['id']; $id = $result['id'];
// paramters // parameters
$password = $this->getParam('mysql_password', true, ''); $password = $this->getParam('mysql_password', true, '');
$databasedescription = $this->getParam('description', true, ''); $databasedescription = $this->getParam('description', true, $result['description']);
// validation // validation
$password = \Froxlor\Validate\Validate::validate($password, 'password', '', '', array(), true); $password = \Froxlor\Validate\Validate::validate($password, 'password', '', '', array(), true);
@@ -350,7 +359,7 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
$result = $this->apiCall('Mysqls.get', array( $result = $this->apiCall('Mysqls.get', array(
'dbname' => $result['databasename'] 'dbname' => $result['databasename']
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
/** /**
@@ -421,14 +430,14 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
Database::needRoot(false); Database::needRoot(false);
} }
} }
return $this->response(200, "successfull", array( return $this->response(200, "successful", array(
'count' => count($result), 'count' => count($result),
'list' => $result 'list' => $result
)); ));
} }
/** /**
* returns the total number of accessable databases * returns the total number of accessible databases
* *
* @param int $customerid * @param int $customerid
* optional, admin-only, select dbs of a specific customer by id * optional, admin-only, select dbs of a specific customer by id
@@ -448,7 +457,7 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
"); ");
$result = Database::pexecute_first($result_stmt, null, true, true); $result = Database::pexecute_first($result_stmt, null, true, true);
if ($result) { if ($result) {
return $this->response(200, "successfull", $result['num_dbs']); return $this->response(200, "successful", $result['num_dbs']);
} }
} }
@@ -462,9 +471,9 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
* @param int $mysql_server * @param int $mysql_server
* optional, specify database-server, default is none * optional, specify database-server, default is none
* @param int $customerid * @param int $customerid
* optional, admin-only, the customer-id * optional, required when called as admin (if $loginname is not specified)
* @param string $loginname * @param string $loginname
* optional, admin-only, the loginname * optional, required when called as admin (if $customerid is not specified)
* *
* @access admin, customer * @access admin, customer
* @throws \Exception * @throws \Exception
@@ -510,6 +519,6 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
Customers::decreaseUsage($customer['customerid'], 'mysqls_used', $resetaccnumber); Customers::decreaseUsage($customer['customerid'], 'mysqls_used', $resetaccnumber);
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_WARNING, "[API] deleted database '" . $result['databasename'] . "'"); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_WARNING, "[API] deleted database '" . $result['databasename'] . "'");
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
} }

View File

@@ -59,7 +59,7 @@ class PhpSettings extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
); );
$query = "SELECT * FROM `" . TABLE_PANEL_DOMAINS . "` $query = "SELECT * FROM `" . TABLE_PANEL_DOMAINS . "`
WHERE `phpsettingid` = :id"; WHERE `phpsettingid` = :id AND `email_only` = '0' AND `phpenabled` = '1'";
if (! $with_subdomains) { if (! $with_subdomains) {
$query .= " AND `parentdomainid` = '0'"; $query .= " AND `parentdomainid` = '0'";
@@ -113,7 +113,7 @@ class PhpSettings extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
$phpconfigs[] = $row; $phpconfigs[] = $row;
} }
return $this->response(200, "successfull", array( return $this->response(200, "successful", array(
'count' => count($phpconfigs), 'count' => count($phpconfigs),
'list' => $phpconfigs 'list' => $phpconfigs
)); ));
@@ -122,7 +122,7 @@ class PhpSettings extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
} }
/** /**
* returns the total number of accessable php-setting entries * returns the total number of accessible php-setting entries
* *
* @access admin * @access admin
* @throws \Exception * @throws \Exception
@@ -137,7 +137,7 @@ class PhpSettings extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
"); ");
$result = Database::pexecute_first($result_stmt, null, true, true); $result = Database::pexecute_first($result_stmt, null, true, true);
if ($result) { if ($result) {
return $this->response(200, "successfull", $result['num_phps']); return $this->response(200, "successful", $result['num_phps']);
} }
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
@@ -165,7 +165,7 @@ class PhpSettings extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
'id' => $id 'id' => $id
), true, true); ), true, true);
if ($result) { if ($result) {
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
throw new \Exception("php-config with id #" . $id . " could not be found", 404); throw new \Exception("php-config with id #" . $id . " could not be found", 404);
} }
@@ -367,7 +367,7 @@ class PhpSettings extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
$result = $this->apiCall('PhpSettings.get', array( $result = $this->apiCall('PhpSettings.get', array(
'id' => $ins_data['id'] 'id' => $ins_data['id']
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
} }
@@ -563,7 +563,7 @@ class PhpSettings extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
$result = $this->apiCall('PhpSettings.get', array( $result = $this->apiCall('PhpSettings.get', array(
'id' => $id 'id' => $id
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
} }
@@ -614,7 +614,7 @@ class PhpSettings extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
\Froxlor\System\Cronjob::inserttask('1'); \Froxlor\System\Cronjob::inserttask('1');
$this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "[API] php setting '" . $result['description'] . "' has been deleted by '" . $this->getUserDetail('loginname') . "'"); $this->logger()->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_INFO, "[API] php setting '" . $result['description'] . "' has been deleted by '" . $this->getUserDetail('loginname') . "'");
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
} }

View File

@@ -2,6 +2,7 @@
namespace Froxlor\Api\Commands; namespace Froxlor\Api\Commands;
use Froxlor\Database\Database; use Froxlor\Database\Database;
use Froxlor\Domain\Domain;
use Froxlor\Settings; use Froxlor\Settings;
/** /**
@@ -36,7 +37,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
* @param string $url * @param string $url
* optional, overwrites path value with an URL to generate a redirect, alternatively use the path parameter also for URLs * optional, overwrites path value with an URL to generate a redirect, alternatively use the path parameter also for URLs
* @param int $openbasedir_path * @param int $openbasedir_path
* optional, either 0 for customers-homedir or 1 for domains-docroot * optional, either 0 for domains-docroot or 1 for customers-homedir
* @param int $phpsettingid * @param int $phpsettingid
* optional, php-settings-id, if empty the $domain value is used * optional, php-settings-id, if empty the $domain value is used
* @param int $redirectcode * @param int $redirectcode
@@ -56,7 +57,9 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
* @param bool $hsts_preload * @param bool $hsts_preload
* optional whether or not to preload HSTS header value, default 0 * optional whether or not to preload HSTS header value, default 0
* @param int $customerid * @param int $customerid
* required when called as admin, not needed when called as customer * optional, required when called as admin (if $loginname is not specified)
* @param string $loginname
* optional, required when called as admin (if $customerid is not specified)
* *
* @access admin, customer * @access admin, customer
* @throws \Exception * @throws \Exception
@@ -228,6 +231,15 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
} }
} }
// validate dns if lets encrypt is enabled to check whether we can use it at all
if ($letsencrypt == '1' && Settings::Get('system.le_domain_dnscheck') == '1') {
$our_ips = Domain::getIpsOfDomain($domain_check['id']);
$domain_ips = \Froxlor\PhpHelper::gethostbynamel6($completedomain);
if ($domain_ips == false || count(array_intersect($our_ips, $domain_ips)) <= 0) {
\Froxlor\UI\Response::standard_error('invaliddnsforletsencrypt', '', true);
}
}
// Temporarily deactivate ssl_redirect until Let's Encrypt certificate was generated // Temporarily deactivate ssl_redirect until Let's Encrypt certificate was generated
if ($ssl_redirect > 0 && $letsencrypt == 1) { if ($ssl_redirect > 0 && $letsencrypt == 1) {
$ssl_redirect = 2; $ssl_redirect = 2;
@@ -345,7 +357,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
$result = $this->apiCall('SubDomains.get', array( $result = $this->apiCall('SubDomains.get', array(
'id' => $subdomain_id 'id' => $subdomain_id
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
throw new \Exception("No more resources available", 406); throw new \Exception("No more resources available", 406);
} }
@@ -426,7 +438,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
$result = Database::pexecute_first($result_stmt, $params, true, true); $result = Database::pexecute_first($result_stmt, $params, true, true);
if ($result) { if ($result) {
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] get subdomain '" . $result['domain'] . "'"); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] get subdomain '" . $result['domain'] . "'");
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
$key = ($id > 0 ? "id #" . $id : "domainname '" . $domainname . "'"); $key = ($id > 0 ? "id #" . $id : "domainname '" . $domainname . "'");
throw new \Exception("Subdomain with " . $key . " could not be found", 404); throw new \Exception("Subdomain with " . $key . " could not be found", 404);
@@ -450,7 +462,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
* @param bool $isemaildomain * @param bool $isemaildomain
* optional * optional
* @param int $openbasedir_path * @param int $openbasedir_path
* optional, either 0 for customers-homedir or 1 for domains-docroot * optional, either 0 for domains-docroot or 1 for customers-homedir
* @param int $phpsettingid * @param int $phpsettingid
* optional, php-settings-id, if empty the $domain value is used * optional, php-settings-id, if empty the $domain value is used
* @param int $redirectcode * @param int $redirectcode
@@ -470,7 +482,9 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
* @param bool $hsts_preload * @param bool $hsts_preload
* optional whether or not to preload HSTS header value * optional whether or not to preload HSTS header value
* @param int $customerid * @param int $customerid
* required when called as admin, not needed when called as customer * optional, required when called as admin (if $loginname is not specified)
* @param string $loginname
* optional, required when called as admin (if $customerid is not specified)
* *
* @access admin, customer * @access admin, customer
* @throws \Exception * @throws \Exception
@@ -591,6 +605,15 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
} }
} }
// validate dns if lets encrypt is enabled to check whether we can use it at all
if ($result['letsencrypt'] != $letsencrypt && $letsencrypt == '1' && Settings::Get('system.le_domain_dnscheck') == '1') {
$our_ips = Domain::getIpsOfDomain($result['parentdomainid']);
$domain_ips = \Froxlor\PhpHelper::gethostbynamel6($result['domain']);
if ($domain_ips == false || count(array_intersect($our_ips, $domain_ips)) <= 0) {
\Froxlor\UI\Response::standard_error('invaliddnsforletsencrypt', '', true);
}
}
// We can't enable let's encrypt for wildcard-domains // We can't enable let's encrypt for wildcard-domains
if ($iswildcarddomain == '1' && $letsencrypt == '1') { if ($iswildcarddomain == '1' && $letsencrypt == '1') {
\Froxlor\UI\Response::standard_error('nowildcardwithletsencrypt'); \Froxlor\UI\Response::standard_error('nowildcardwithletsencrypt');
@@ -620,7 +643,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
\Froxlor\Domain\Domain::updateRedirectOfDomain($id, $redirectcode); \Froxlor\Domain\Domain::updateRedirectOfDomain($id, $redirectcode);
} }
if ($path != $result['documentroot'] || $isemaildomain != $result['isemaildomain'] || $wwwserveralias != $result['wwwserveralias'] || $iswildcarddomain != $result['iswildcarddomain'] || $aliasdomain != $result['aliasdomain'] || $openbasedir_path != $result['openbasedir_path'] || $ssl_redirect != $result['ssl_redirect'] || $letsencrypt != $result['letsencrypt'] || $hsts_maxage != $result['hsts'] || $hsts_sub != $result['hsts_sub'] || $hsts_preload != $result['hsts_preload'] || $phpsettingid != $result['phpsettingid']) { if ($path != $result['documentroot'] || $isemaildomain != $result['isemaildomain'] || $wwwserveralias != $result['wwwserveralias'] || $iswildcarddomain != $result['iswildcarddomain'] || $aliasdomain != (int)$result['aliasdomain'] || $openbasedir_path != $result['openbasedir_path'] || $ssl_redirect != $result['ssl_redirect'] || $letsencrypt != $result['letsencrypt'] || $hsts_maxage != $result['hsts'] || $hsts_sub != $result['hsts_sub'] || $hsts_preload != $result['hsts_preload'] || $phpsettingid != $result['phpsettingid']) {
$stmt = Database::prepare(" $stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_DOMAINS . "` SET UPDATE `" . TABLE_PANEL_DOMAINS . "` SET
`documentroot` = :documentroot, `documentroot` = :documentroot,
@@ -683,6 +706,8 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
Database::pexecute($del_stmt, array( Database::pexecute($del_stmt, array(
'id' => $id 'id' => $id
), true, true); ), true, true);
// remove domain from acme.sh / lets encrypt if used
\Froxlor\System\Cronjob::inserttask('12', $result['domain']);
} }
\Froxlor\System\Cronjob::inserttask('1'); \Froxlor\System\Cronjob::inserttask('1');
@@ -693,7 +718,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
$result = $this->apiCall('SubDomains.get', array( $result = $this->apiCall('SubDomains.get', array(
'id' => $id 'id' => $id
)); ));
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
/** /**
@@ -797,14 +822,14 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
while ($row = $domains_stmt->fetch(\PDO::FETCH_ASSOC)) { while ($row = $domains_stmt->fetch(\PDO::FETCH_ASSOC)) {
$result[] = $row; $result[] = $row;
} }
return $this->response(200, "successfull", array( return $this->response(200, "successful", array(
'count' => count($result), 'count' => count($result),
'list' => $result 'list' => $result
)); ));
} }
/** /**
* returns the total number of accessable subdomain entries * returns the total number of accessible subdomain entries
* *
* @param int $customerid * @param int $customerid
* optional, admin-only, select (sub)domains of a specific customer by id * optional, admin-only, select (sub)domains of a specific customer by id
@@ -862,7 +887,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
"); ");
$result = Database::pexecute_first($domains_stmt, null, true, true); $result = Database::pexecute_first($domains_stmt, null, true, true);
if ($result) { if ($result) {
return $this->response(200, "successfull", $result['num_subdom']); return $this->response(200, "successful", $result['num_subdom']);
} }
} }
@@ -873,6 +898,10 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
* optional, the domain-id * optional, the domain-id
* @param string $domainname * @param string $domainname
* optional, the domainname * optional, the domainname
* @param int $customerid
* optional, required when called as admin (if $loginname is not specified)
* @param string $loginname
* optional, required when called as admin (if $customerid is not specified)
* *
* @access admin, customer * @access admin, customer
* @throws \Exception * @throws \Exception
@@ -976,7 +1005,7 @@ class SubDomains extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resourc
Customers::decreaseUsage($customer['customerid'], 'subdomains_used'); Customers::decreaseUsage($customer['customerid'], 'subdomains_used');
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_WARNING, "[API] deleted subdomain '" . $result['domain'] . "'"); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_WARNING, "[API] deleted subdomain '" . $result['domain'] . "'");
return $this->response(200, "successfull", $result); return $this->response(200, "successful", $result);
} }
/** /**

View File

@@ -74,7 +74,7 @@ class SysLog extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
$result[] = $row; $result[] = $row;
} }
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] list log-entries"); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] list log-entries");
return $this->response(200, "successfull", array( return $this->response(200, "successful", array(
'count' => count($result), 'count' => count($result),
'list' => $result 'list' => $result
)); ));
@@ -129,7 +129,7 @@ class SysLog extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
$result = Database::pexecute_first($result_stmt, $params, true, true); $result = Database::pexecute_first($result_stmt, $params, true, true);
if ($result) { if ($result) {
return $this->response(200, "successfull", $result['num_logs']); return $this->response(200, "successful", $result['num_logs']);
} }
} }
@@ -204,7 +204,7 @@ class SysLog extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
$params['trunc'] = $truncatedate; $params['trunc'] = $truncatedate;
Database::pexecute($result_stmt, $params, true, true); Database::pexecute($result_stmt, $params, true, true);
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_WARNING, "[API] truncated the froxlor syslog"); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_WARNING, "[API] truncated the froxlor syslog");
return $this->response(200, "successfull", true); return $this->response(200, "successful", true);
} }
throw new \Exception("Not allowed to execute given command.", 403); throw new \Exception("Not allowed to execute given command.", 403);
} }

View File

@@ -60,6 +60,10 @@ class Traffic extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
* optional, default empty * optional, default empty
* @param int $day * @param int $day
* optional, default empty * optional, default empty
* @param int $date_from
* optional timestamp, default empty, if specified, $year, $month and $day will be ignored
* @param int $date_until
* optional timestamp, default empty, if specified, $year, $month and $day will be ignored
* @param bool $customer_traffic * @param bool $customer_traffic
* optional, admin-only, whether to output ones own traffic or all of ones customers, default is 0 (false) * optional, admin-only, whether to output ones own traffic or all of ones customers, default is 0 (false)
* @param int $customerid * @param int $customerid
@@ -76,10 +80,29 @@ class Traffic extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
$year = $this->getParam('year', true, ""); $year = $this->getParam('year', true, "");
$month = $this->getParam('month', true, ""); $month = $this->getParam('month', true, "");
$day = $this->getParam('day', true, ""); $day = $this->getParam('day', true, "");
$date_from = $this->getParam('date_from', true, - 1);
$date_until = $this->getParam('date_until', true, - 1);
$customer_traffic = $this->getBoolParam('customer_traffic', true, 0); $customer_traffic = $this->getBoolParam('customer_traffic', true, 0);
$customer_ids = $this->getAllowedCustomerIds(); $customer_ids = $this->getAllowedCustomerIds();
$result = array(); $result = array();
$params = array(); $params = array();
// validate parameters
if ($date_from >= 0 || $date_until >= 0) {
$year = "";
$month = "";
$day = "";
if ($date_from == $date_until) {
$date_until = -1;
}
if ($date_from >= 0 && $date_until >= 0 && $date_until < $date_from) {
// switch
$temp_ts = $date_from;
$date_from = $date_until;
$date_until = $temp_ts;
}
}
// check for year/month/day // check for year/month/day
$where_str = ""; $where_str = "";
if (! empty($year) && is_numeric($year)) { if (! empty($year) && is_numeric($year)) {
@@ -94,6 +117,17 @@ class Traffic extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
$where_str .= " AND `day` = :day"; $where_str .= " AND `day` = :day";
$params['day'] = $day; $params['day'] = $day;
} }
if ($date_from >= 0 && $date_until >= 0) {
$where_str .= " AND `stamp` BETWEEN :df AND :du";
$params['df'] = $date_from;
$params['du'] = $date_until;
} elseif ($date_from >= 0 && $date_until < 0) {
$where_str .= " AND `stamp` > :df";
$params['df'] = $date_from;
} elseif ($date_from < 0 && $date_until >= 0) {
$where_str .= " AND `stamp` < :du";
$params['du'] = $date_until;
}
if (! $this->isAdmin() || ($this->isAdmin() && $customer_traffic)) { if (! $this->isAdmin() || ($this->isAdmin() && $customer_traffic)) {
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
@@ -110,7 +144,7 @@ class Traffic extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEn
$result[] = $row; $result[] = $row;
} }
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] list traffic"); $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "[API] list traffic");
return $this->response(200, "successfull", array( return $this->response(200, "successful", array(
'count' => count($result), 'count' => count($result),
'list' => $result 'list' => $result
)); ));

View File

@@ -35,20 +35,6 @@ abstract class BulkAction
*/ */
private $impFile = null; private $impFile = null;
/**
* customer id of the user the entity is being added to
*
* @var int
*/
private $custId = null;
/**
* array of customer data read from the database
*
* @var array
*/
private $custData = null;
/** /**
* api-function to call for addingg entity * api-function to call for addingg entity
* *
@@ -70,20 +56,27 @@ abstract class BulkAction
*/ */
private $errors = array(); private $errors = array();
/**
* logged in user
*
* @var array
*/
protected $userinfo = array();
/** /**
* class constructor, optionally sets file and customer-id * class constructor, optionally sets file and customer-id
* *
* @param string $import_file * @param string $import_file
* @param int $customer_id * @param array $userinfo
* *
* @return object BulkAction instance * @return object BulkAction instance
*/ */
protected function __construct($import_file = null, $customer_id = 0) protected function __construct($import_file = null, $userinfo = array())
{ {
if (! empty($import_file)) { if (! empty($import_file)) {
$this->impFile = \Froxlor\FileDir::makeCorrectFile($import_file); $this->impFile = \Froxlor\FileDir::makeCorrectFile($import_file);
} }
$this->custId = $customer_id; $this->userinfo = $userinfo;
} }
/** /**
@@ -109,18 +102,6 @@ abstract class BulkAction
$this->impFile = \Froxlor\FileDir::makeCorrectFile($import_file); $this->impFile = \Froxlor\FileDir::makeCorrectFile($import_file);
} }
/**
* setter for customer-id
*
* @param int $customer_id
*
* @return void
*/
public function setCustomer($customer_id = 0)
{
$this->custId = $customer_id;
}
/** /**
* return the list of errors * return the list of errors
* *
@@ -145,7 +126,7 @@ abstract class BulkAction
protected function importEntity($data_array = null) protected function importEntity($data_array = null)
{ {
global $userinfo; if (empty($data_array)) return null;
$module = '\\Froxlor\\Api\\Commands\\' . substr($this->api_call, 0, strpos($this->api_call, ".")); $module = '\\Froxlor\\Api\\Commands\\' . substr($this->api_call, 0, strpos($this->api_call, "."));
$function = substr($this->api_call, strpos($this->api_call, ".") + 1); $function = substr($this->api_call, strpos($this->api_call, ".") + 1);
@@ -159,7 +140,7 @@ abstract class BulkAction
$result = null; $result = null;
try { try {
$json_result = $module::getLocal($userinfo, $new_data)->$function(); $json_result = $module::getLocal($this->userinfo, $new_data)->$function();
$result = json_decode($json_result, true)['data']; $result = json_decode($json_result, true)['data'];
} catch (\Exception $e) { } catch (\Exception $e) {
$this->errors[] = $e->getMessage(); $this->errors[] = $e->getMessage();
@@ -169,7 +150,7 @@ abstract class BulkAction
/** /**
* reads in the csv import file and returns an array with * reads in the csv import file and returns an array with
* all the entites to be imported * all the entities to be imported
* *
* @param string $separator * @param string $separator
* *
@@ -189,6 +170,10 @@ abstract class BulkAction
throw new \Exception("Unable to read file '" . $this->impFile . "'"); throw new \Exception("Unable to read file '" . $this->impFile . "'");
} }
if (empty($separator) || strlen($separator) != 1) {
throw new \Exception("Invalid separator specified: '" . $separator . "'");
}
$file_data = array(); $file_data = array();
$is_params_line = true; $is_params_line = true;
$fh = @fopen($this->impFile, "r"); $fh = @fopen($this->impFile, "r");
@@ -218,37 +203,4 @@ abstract class BulkAction
return $file_data; return $file_data;
} }
/**
* to be called first in doImport() to read in customer and entity data
*/
protected function preImport()
{
$this->readCustomerData();
if ($this->custId <= 0) {
throw new \Exception("Invalid customer selected");
}
if (is_null($this->custData)) {
throw new \Exception("Failed to read customer data");
}
}
/**
* reads customer data from panel_customer by $_custId
*
* @return bool
*/
protected function readCustomerData()
{
$cust_stmt = \Froxlor\Database\Database::prepare("SELECT * FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `customerid` = :cid");
$this->custData = \Froxlor\Database\Database::pexecute_first($cust_stmt, array(
'cid' => $this->custId
));
if (is_array($this->custData) && isset($this->custData['customerid']) && $this->custData['customerid'] == $this->custId) {
return true;
}
$this->custData = null;
return false;
}
} }

View File

@@ -32,9 +32,9 @@ class DomainBulkAction extends BulkAction
* *
* @return object DomainBulkAction instance * @return object DomainBulkAction instance
*/ */
public function __construct($import_file = null, $customer_id = 0) public function __construct($import_file = null, $userinfo)
{ {
parent::__construct($import_file, $customer_id); parent::__construct($import_file, $userinfo);
$this->setApiCall('Domains.add'); $this->setApiCall('Domains.add');
} }
@@ -49,23 +49,14 @@ class DomainBulkAction extends BulkAction
*/ */
public function doImport($separator = ";", $offset = 0) public function doImport($separator = ";", $offset = 0)
{ {
$this->preImport(); if ($this->userinfo['domains'] == "-1") {
// get the admins userinfo to check for domains_used, etc.
global $userinfo;
if ($userinfo['domains'] == "-1") {
$dom_unlimited = true; $dom_unlimited = true;
} else { } else {
$dom_unlimited = false; $dom_unlimited = false;
} }
$domains_used = (int) $userinfo['domains_used']; $domains_used = (int) $this->userinfo['domains_used'];
$domains_avail = (int) $userinfo['domains']; $domains_avail = (int) $this->userinfo['domains'];
if (empty($separator) || strlen($separator) != 1) {
throw new \Exception("Invalid separator specified: '" . $separator . "'");
}
if (! is_int($offset) || $offset < 0) { if (! is_int($offset) || $offset < 0) {
throw new \Exception("Invalid offset specified"); throw new \Exception("Invalid offset specified");

View File

@@ -26,11 +26,16 @@ class ConfigServicesAction extends \Froxlor\Cli\Action
*/ */
private function validate() private function validate()
{ {
global $lng;
$this->checkConfigParam(true); $this->checkConfigParam(true);
$this->parseConfig(); $this->parseConfig();
require FROXLOR_INSTALL_DIR . '/lib/tables.inc.php'; require FROXLOR_INSTALL_DIR . '/lib/tables.inc.php';
include_once FROXLOR_INSTALL_DIR . '/lng/english.lng.php';
include_once FROXLOR_INSTALL_DIR . '/lng/lng_references.php';
if (array_key_exists("import-settings", $this->_args)) { if (array_key_exists("import-settings", $this->_args)) {
$this->importSettings(); $this->importSettings();
} }
@@ -78,6 +83,20 @@ class ConfigServicesAction extends \Froxlor\Cli\Action
$distros = glob($config_dir . '*.xml'); $distros = glob($config_dir . '*.xml');
// tmp array // tmp array
$distributions_select_data = array(); $distributions_select_data = array();
//set default os.
$os_dist = array('ID' => 'buster');
$os_version = array('0' => '10');
$os_default = $os_dist['ID'];
//read os-release
if(file_exists('/etc/os-release')) {
$os_dist = parse_ini_file('/etc/os-release', false);
if(is_array($os_dist) && array_key_exists('ID', $os_dist) && array_key_exists('VERSION_ID', $os_dist)) {
$os_version = explode('.',$os_dist['VERSION_ID'])[0];
}
}
// read in all the distros // read in all the distros
foreach ($distros as $_distribution) { foreach ($distros as $_distribution) {
// get configparser object // get configparser object
@@ -86,6 +105,12 @@ class ConfigServicesAction extends \Froxlor\Cli\Action
$dist_display = $this->getCompleteDistroName($dist); $dist_display = $this->getCompleteDistroName($dist);
// store in tmp array // store in tmp array
$distributions_select_data[$dist_display] = str_replace(".xml", "", strtolower(basename($_distribution))); $distributions_select_data[$dist_display] = str_replace(".xml", "", strtolower(basename($_distribution)));
//guess if this is the current distro.
$ver = explode('.', $dist->distributionVersion)[0];
if (strtolower($os_dist['ID']) == strtolower($dist->distributionName) && $os_version == $ver) {
$os_default = str_replace(".xml", "", strtolower(basename($_distribution)));
}
} }
// sort by distribution name // sort by distribution name
@@ -103,7 +128,7 @@ class ConfigServicesAction extends \Froxlor\Cli\Action
echo PHP_EOL; echo PHP_EOL;
while (! in_array($_daemons_config['distro'], $distributions_select_data)) { while (! in_array($_daemons_config['distro'], $distributions_select_data)) {
$_daemons_config['distro'] = ConfigServicesCmd::getInput("choose distribution", "buster"); $_daemons_config['distro'] = ConfigServicesCmd::getInput("choose distribution", $os_default);
} }
// go through all services and let user check whether to include it or not // go through all services and let user check whether to include it or not
@@ -377,7 +402,7 @@ class ConfigServicesAction extends \Froxlor\Cli\Action
} elseif (! file_exists($this->_args["froxlor-dir"])) { } elseif (! file_exists($this->_args["froxlor-dir"])) {
throw new \Exception("Given froxlor directory cannot be found ('" . $this->_args["froxlor-dir"] . "')"); throw new \Exception("Given froxlor directory cannot be found ('" . $this->_args["froxlor-dir"] . "')");
} elseif (! is_readable($this->_args["froxlor-dir"])) { } elseif (! is_readable($this->_args["froxlor-dir"])) {
throw new \Exception("Given froxlor direcotry cannot be read ('" . $this->_args["froxlor-dir"] . "')"); throw new \Exception("Given froxlor directory cannot be read ('" . $this->_args["froxlor-dir"] . "')");
} }
} }
} }

View File

@@ -62,7 +62,7 @@ class SwitchServerIpAction extends \Froxlor\Cli\Action
$ip_list = $this->_args['switch']; $ip_list = $this->_args['switch'];
if (empty($ip_list) || is_bool($ip_list)) { if (empty($ip_list) || is_bool($ip_list)) {
throw new \Exception("No paramters given for --switch action."); throw new \Exception("No parameters given for --switch action.");
} }
$ips_to_switch = array(); $ips_to_switch = array();
@@ -179,7 +179,7 @@ class SwitchServerIpAction extends \Froxlor\Cli\Action
} elseif (! file_exists($this->_args["froxlor-dir"])) { } elseif (! file_exists($this->_args["froxlor-dir"])) {
throw new \Exception("Given froxlor directory cannot be found ('" . $this->_args["froxlor-dir"] . "')"); throw new \Exception("Given froxlor directory cannot be found ('" . $this->_args["froxlor-dir"] . "')");
} elseif (! is_readable($this->_args["froxlor-dir"])) { } elseif (! is_readable($this->_args["froxlor-dir"])) {
throw new \Exception("Given froxlor direcotry cannot be read ('" . $this->_args["froxlor-dir"] . "')"); throw new \Exception("Given froxlor directory cannot be read ('" . $this->_args["froxlor-dir"] . "')");
} }
} }
} }

View File

@@ -55,7 +55,7 @@ class ConfigDaemon
private $isparsed = false; private $isparsed = false;
/** /**
* Sub - area of the full - XML only holding the daemon - data we are interessted in * Sub - area of the full - XML only holding the daemon - data we are interested in
* *
* @var \SimpleXMLElement * @var \SimpleXMLElement
*/ */

View File

@@ -39,6 +39,13 @@ class ConfigParser
*/ */
private $services = array(); private $services = array();
/**
* Holding the available defaults in the XML
*
* @var array
*/
private $defaults = array();
/** /**
* Store the parsed SimpleXMLElement for usage * Store the parsed SimpleXMLElement for usage
* *
@@ -147,7 +154,7 @@ class ConfigParser
* *
* @return bool * @return bool
*/ */
private function parse() private function parseServices()
{ {
// We only want to parse the stuff one time // We only want to parse the stuff one time
if ($this->isparsed == true) { if ($this->isparsed == true) {
@@ -174,6 +181,29 @@ class ConfigParser
return true; return true;
} }
/**
* Parse the XML and populate $this->services
*
* @return bool
*/
private function parseDefaults()
{
// We only want to parse the stuff one time
if ($this->isparsed == true) {
return true;
}
// Get all defaults
$defaults = $this->xml->xpath('//defaults');
foreach ($defaults as $default) {
$this->defaults = $default;
}
// Switch flag to indicate we parsed our data
$this->isparsed = true;
return true;
}
/** /**
* Return all services defined by the XML * Return all services defined by the XML
* *
@@ -184,9 +214,25 @@ class ConfigParser
public function getServices() public function getServices()
{ {
// Let's parse this shit(!) // Let's parse this shit(!)
$this->parse(); $this->parseServices();
// Return our carefully searched for services // Return our carefully searched for services
return $this->services; return $this->services;
} }
/**
* Return all defaults defined by the XML
*
* The array will hold ConfigDefaults - Objects for further handling
*
* @return array
*/
public function getDefaults()
{
// Let's parse this shit(!)
$this->parseDefaults();
// Return our carefully searched for defaults
return $this->defaults;
}
} }

View File

@@ -41,6 +41,7 @@ abstract class DnsBase
{ {
$this->logger = $logger; $this->logger = $logger;
$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) {
@@ -58,6 +59,8 @@ abstract class DnsBase
$nameserver_ips = array( $nameserver_ips = array(
$nameserver $nameserver
); );
} else {
$known_ns_ips = array_merge($known_ns_ips, $nameserver_ips);
} }
$this->ns[] = array( $this->ns[] = array(
'hostname' => $nameserver, 'hostname' => $nameserver,
@@ -80,10 +83,12 @@ abstract class DnsBase
if (Settings::Get('system.axfrservers') != '') { if (Settings::Get('system.axfrservers') != '') {
$axfrservers = explode(',', Settings::Get('system.axfrservers')); $axfrservers = explode(',', Settings::Get('system.axfrservers'));
foreach ($axfrservers as $axfrserver) { foreach ($axfrservers as $axfrserver) {
if (!in_array(trim($axfrserver), $known_ns_ips)) {
$this->axfr[] = trim($axfrserver); $this->axfr[] = trim($axfrserver);
} }
} }
} }
}
protected function getDomainList() protected function getDomainList()
{ {
@@ -195,18 +200,18 @@ abstract class DnsBase
while ($domain = $result_domains_stmt->fetch(\PDO::FETCH_ASSOC)) { while ($domain = $result_domains_stmt->fetch(\PDO::FETCH_ASSOC)) {
$privkey_filename = \Froxlor\FileDir::makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/dkim_' . $domain['dkim_id']); $privkey_filename = \Froxlor\FileDir::makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/dkim' . $domain['dkim_id'] . Settings::Get('dkim.privkeysuffix'));
$pubkey_filename = \Froxlor\FileDir::makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/dkim_' . $domain['dkim_id'] . '.public'); $pubkey_filename = \Froxlor\FileDir::makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/dkim' . $domain['dkim_id'] . '.public');
if ($domain['dkim_privkey'] == '' || $domain['dkim_pubkey'] == '') { if ($domain['dkim_privkey'] == '' || $domain['dkim_pubkey'] == '') {
$max_dkim_id_stmt = Database::query("SELECT MAX(`dkim_id`) as `max_dkim_id` FROM `" . TABLE_PANEL_DOMAINS . "`"); $max_dkim_id_stmt = Database::query("SELECT MAX(`dkim_id`) as `max_dkim_id` FROM `" . TABLE_PANEL_DOMAINS . "`");
$max_dkim_id = $max_dkim_id_stmt->fetch(\PDO::FETCH_ASSOC); $max_dkim_id = $max_dkim_id_stmt->fetch(\PDO::FETCH_ASSOC);
$domain['dkim_id'] = (int) $max_dkim_id['max_dkim_id'] + 1; $domain['dkim_id'] = (int) $max_dkim_id['max_dkim_id'] + 1;
$privkey_filename = \Froxlor\FileDir::makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/dkim_' . $domain['dkim_id']); $privkey_filename = \Froxlor\FileDir::makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/dkim' . $domain['dkim_id'] . Settings::Get('dkim.privkeysuffix'));
\Froxlor\FileDir::safe_exec('openssl genrsa -out ' . escapeshellarg($privkey_filename) . ' ' . Settings::Get('dkim.dkim_keylength')); \Froxlor\FileDir::safe_exec('openssl genrsa -out ' . escapeshellarg($privkey_filename) . ' ' . Settings::Get('dkim.dkim_keylength'));
$domain['dkim_privkey'] = file_get_contents($privkey_filename); $domain['dkim_privkey'] = file_get_contents($privkey_filename);
\Froxlor\FileDir::safe_exec("chmod 0640 " . escapeshellarg($privkey_filename)); \Froxlor\FileDir::safe_exec("chmod 0640 " . escapeshellarg($privkey_filename));
$pubkey_filename = \Froxlor\FileDir::makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/dkim_' . $domain['dkim_id'] . '.public'); $pubkey_filename = \Froxlor\FileDir::makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/dkim' . $domain['dkim_id'] . '.public');
\Froxlor\FileDir::safe_exec('openssl rsa -in ' . escapeshellarg($privkey_filename) . ' -pubout -outform pem -out ' . escapeshellarg($pubkey_filename)); \Froxlor\FileDir::safe_exec('openssl rsa -in ' . escapeshellarg($privkey_filename) . ' -pubout -outform pem -out ' . escapeshellarg($pubkey_filename));
$domain['dkim_pubkey'] = file_get_contents($pubkey_filename); $domain['dkim_pubkey'] = file_get_contents($pubkey_filename);
\Froxlor\FileDir::safe_exec("chmod 0664 " . escapeshellarg($pubkey_filename)); \Froxlor\FileDir::safe_exec("chmod 0664 " . escapeshellarg($pubkey_filename));

View File

@@ -1,6 +1,8 @@
<?php <?php
namespace Froxlor\Cron\Dns; namespace Froxlor\Cron\Dns;
use Froxlor\Settings;
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2016 the Froxlor Team (see authors). * Copyright (c) 2016 the Froxlor Team (see authors).
@@ -112,14 +114,15 @@ class PowerDNS extends DnsBase
private function insertZone($domainname, $serial = 0) private function insertZone($domainname, $serial = 0)
{ {
$ins_stmt = \Froxlor\Dns\PowerDNS::getDB()->prepare(" $ins_stmt = \Froxlor\Dns\PowerDNS::getDB()->prepare("
INSERT INTO domains set `name` = :domainname, `notified_serial` = :serial, `type` = 'NATIVE' INSERT INTO domains set `name` = :domainname, `notified_serial` = :serial, `type` = :type
"); ");
$ins_stmt->execute(array( $ins_stmt->execute(array(
'domainname' => $domainname, 'domainname' => $domainname,
'serial' => $serial 'serial' => $serial,
'type' => strtoupper(Settings::Get('system.powerdns_mode'))
)); ));
$lastid = \Froxlor\Dns\PowerDNS::getDB()->lastInsertId(); $lastid = \Froxlor\Dns\PowerDNS::getDB()->lastInsertId();
return $lastid; return $lastid;;
} }
private function insertRecords($domainid = 0, $records = array(), $origin = "") private function insertRecords($domainid = 0, $records = array(), $origin = "")

View File

@@ -413,7 +413,8 @@ class Apache extends HttpConfigBase
$this->virtualhosts_data[$vhosts_filename] .= $this->processSpecialConfigTemplate($row_ipsandports['ssl_specialsettings'], $domain, $row_ipsandports['ip'], $row_ipsandports['port'], $row_ipsandports['ssl'] == '1') . "\n"; $this->virtualhosts_data[$vhosts_filename] .= $this->processSpecialConfigTemplate($row_ipsandports['ssl_specialsettings'], $domain, $row_ipsandports['ip'], $row_ipsandports['port'], $row_ipsandports['ssl'] == '1') . "\n";
} }
if ($row_ipsandports['ssl_cert_file'] == '') { // check for required fallback
if (($row_ipsandports['ssl_cert_file'] == '' || ! file_exists($row_ipsandports['ssl_cert_file'])) && (Settings::Get('system.le_froxlor_enabled') == '0' || $this->froxlorVhostHasLetsEncryptCert() == false)) {
$row_ipsandports['ssl_cert_file'] = Settings::Get('system.ssl_cert_file'); $row_ipsandports['ssl_cert_file'] = Settings::Get('system.ssl_cert_file');
if (! file_exists($row_ipsandports['ssl_cert_file'])) { if (! file_exists($row_ipsandports['ssl_cert_file'])) {
// explicitly disable ssl for this vhost // explicitly disable ssl for this vhost
@@ -424,6 +425,11 @@ class Apache extends HttpConfigBase
if ($row_ipsandports['ssl_key_file'] == '') { if ($row_ipsandports['ssl_key_file'] == '') {
$row_ipsandports['ssl_key_file'] = Settings::Get('system.ssl_key_file'); $row_ipsandports['ssl_key_file'] = Settings::Get('system.ssl_key_file');
if (! file_exists($row_ipsandports['ssl_key_file'])) {
// explicitly disable ssl for this vhost
$row_ipsandports['ssl_cert_file'] = "";
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(\Froxlor\FroxlorLogger::CRON_ACTION, LOG_DEBUG, 'System certificate key-file "' . Settings::Get('system.ssl_key_file') . '" does not seem to exist. Disabling SSL-vhost for "' . Settings::Get('system.hostname') . '"');
}
} }
if ($row_ipsandports['ssl_ca_file'] == '') { if ($row_ipsandports['ssl_ca_file'] == '') {
@@ -559,7 +565,7 @@ class Apache extends HttpConfigBase
* *
* @return string * @return string
*/ */
protected function composePhpOptions($domain, $ssl_vhost = false) protected function composePhpOptions(&$domain, $ssl_vhost = false)
{ {
$php_options_text = ''; $php_options_text = '';
@@ -782,14 +788,6 @@ class Apache extends HttpConfigBase
)); ));
$logfiles_text .= ' CustomLog "|' . $command . '" ' . $logtype . "\n"; $logfiles_text .= ' CustomLog "|' . $command . '" ' . $logtype . "\n";
} else { } else {
// Create the logfile if it does not exist (fixes #46)
touch($error_log);
chown($error_log, Settings::Get('system.httpuser'));
chgrp($error_log, Settings::Get('system.httpgroup'));
touch($access_log);
chown($access_log, Settings::Get('system.httpuser'));
chgrp($access_log, Settings::Get('system.httpgroup'));
$logfiles_text .= ' ErrorLog "' . $error_log . '"' . "\n"; $logfiles_text .= ' ErrorLog "' . $error_log . '"' . "\n";
$logfiles_text .= ' CustomLog "' . $access_log . '" ' . $logtype . "\n"; $logfiles_text .= ' CustomLog "' . $access_log . '" ' . $logtype . "\n";
} }
@@ -828,7 +826,7 @@ class Apache extends HttpConfigBase
// After inserting the AWStats information, // After inserting the AWStats information,
// be sure to build the awstats conf file as well // be sure to build the awstats conf file as well
// and chown it using $awstats_params, #258 // and chown it using $awstats_params, #258
// Bug 960 + Bug 970 : Use full $domain instead of custom $awstats_params as following classes depend on the informations // Bug 960 + Bug 970 : Use full $domain instead of custom $awstats_params as following classes depend on the information
\Froxlor\Http\Statistics::createAWStatsConf(Settings::Get('system.logfiles_directory') . $domain['loginname'] . $speciallogfile . '-access.log', $domain['domain'], $alias . $server_alias, $domain['customerroot'], $domain); \Froxlor\Http\Statistics::createAWStatsConf(Settings::Get('system.logfiles_directory') . $domain['loginname'] . $speciallogfile . '-access.log', $domain['domain'], $alias . $server_alias, $domain['customerroot'], $domain);
} }
} }
@@ -950,7 +948,7 @@ class Apache extends HttpConfigBase
} }
if ($ssl_vhost === true && $domain['ssl'] == '1' && Settings::Get('system.use_ssl') == '1') { if ($ssl_vhost === true && $domain['ssl'] == '1' && Settings::Get('system.use_ssl') == '1') {
if ($domain['ssl_cert_file'] == '') { if ($domain['ssl_cert_file'] == '' || ! file_exists($domain['ssl_cert_file'])) {
$domain['ssl_cert_file'] = Settings::Get('system.ssl_cert_file'); $domain['ssl_cert_file'] = Settings::Get('system.ssl_cert_file');
if (! file_exists($domain['ssl_cert_file'])) { if (! file_exists($domain['ssl_cert_file'])) {
// explicitly disable ssl for this vhost // explicitly disable ssl for this vhost
@@ -959,8 +957,13 @@ class Apache extends HttpConfigBase
} }
} }
if ($domain['ssl_key_file'] == '') { if ($domain['ssl_key_file'] == '' || ! file_exists($domain['ssl_key_file'])) {
$domain['ssl_key_file'] = Settings::Get('system.ssl_key_file'); $domain['ssl_key_file'] = Settings::Get('system.ssl_key_file');
if (! file_exists($domain['ssl_key_file'])) {
// explicitly disable ssl for this vhost
$domain['ssl_cert_file'] = "";
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(\Froxlor\FroxlorLogger::CRON_ACTION, LOG_DEBUG, 'System certificate key-file "' . Settings::Get('system.ssl_key_file') . '" does not seem to exist. Disabling SSL-vhost for "' . $domain['domain'] . '"');
}
} }
if ($domain['ssl_ca_file'] == '') { if ($domain['ssl_ca_file'] == '') {

View File

@@ -24,7 +24,7 @@ use Froxlor\Cron\Http\Php\PhpInterface;
class ApacheFcgi extends Apache class ApacheFcgi extends Apache
{ {
protected function composePhpOptions($domain, $ssl_vhost = false) protected function composePhpOptions(&$domain, $ssl_vhost = false)
{ {
$php_options_text = ''; $php_options_text = '';
@@ -43,6 +43,8 @@ class ApacheFcgi extends Apache
$php_options_text .= ' SuexecUserGroup "' . $domain['loginname'] . '" "' . $domain['loginname'] . '"' . "\n"; $php_options_text .= ' SuexecUserGroup "' . $domain['loginname'] . '" "' . $domain['loginname'] . '"' . "\n";
} }
$domain['fpm_socket'] = $php->getInterface()->getSocketFile();
// mod_proxy stuff for apache-2.4 // mod_proxy stuff for apache-2.4
if (Settings::Get('system.apache24') == '1' && Settings::Get('phpfpm.use_mod_proxy') == '1') { if (Settings::Get('system.apache24') == '1' && Settings::Get('phpfpm.use_mod_proxy') == '1') {
$filesmatch = $phpconfig['fpm_settings']['limit_extensions']; $filesmatch = $phpconfig['fpm_settings']['limit_extensions'];
@@ -54,7 +56,7 @@ class ApacheFcgi extends Apache
// start block, cut off last pipe and close block // start block, cut off last pipe and close block
$filesmatch = '(' . str_replace(".", "\.", substr($filesmatch, 0, - 1)) . ')'; $filesmatch = '(' . str_replace(".", "\.", substr($filesmatch, 0, - 1)) . ')';
$php_options_text .= ' <FilesMatch \.' . $filesmatch . '$>' . "\n"; $php_options_text .= ' <FilesMatch \.' . $filesmatch . '$>' . "\n";
$php_options_text .= ' SetHandler proxy:unix:' . $php->getInterface()->getSocketFile() . '|fcgi://localhost' . "\n"; $php_options_text .= ' SetHandler proxy:unix:' . $domain['fpm_socket'] . '|fcgi://localhost' . "\n";
$php_options_text .= ' </FilesMatch>' . "\n"; $php_options_text .= ' </FilesMatch>' . "\n";
$mypath_dir = new \Froxlor\Http\Directory($domain['documentroot']); $mypath_dir = new \Froxlor\Http\Directory($domain['documentroot']);
@@ -80,7 +82,7 @@ class ApacheFcgi extends Apache
if ($phpconfig['pass_authorizationheader'] == '1') { if ($phpconfig['pass_authorizationheader'] == '1') {
$addheader = " -pass-header Authorization"; $addheader = " -pass-header Authorization";
} }
$php_options_text .= ' FastCgiExternalServer ' . $php->getInterface()->getAliasConfigDir() . $srvName . ' -socket ' . $php->getInterface()->getSocketFile() . ' -idle-timeout ' . $phpconfig['fpm_settings']['idle_timeout'] . $addheader . "\n"; $php_options_text .= ' FastCgiExternalServer ' . $php->getInterface()->getAliasConfigDir() . $srvName . ' -socket ' . $domain['fpm_socket'] . ' -idle-timeout ' . $phpconfig['fpm_settings']['idle_timeout'] . $addheader . "\n";
$php_options_text .= ' <Directory "' . \Froxlor\FileDir::makeCorrectDir($domain['documentroot']) . '">' . "\n"; $php_options_text .= ' <Directory "' . \Froxlor\FileDir::makeCorrectDir($domain['documentroot']) . '">' . "\n";
$filesmatch = $phpconfig['fpm_settings']['limit_extensions']; $filesmatch = $phpconfig['fpm_settings']['limit_extensions'];
$extensions = explode(" ", $filesmatch); $extensions = explode(" ", $filesmatch);

View File

@@ -287,7 +287,7 @@ class ConfigIO
} }
/** /**
* returns a file/direcotry from the settings and checks whether it exists * returns a file/directory from the settings and checks whether it exists
* *
* @param string $group * @param string $group
* settings-group * settings-group

View File

@@ -105,7 +105,11 @@ class DomainSSL
$_fh = fopen($filename, 'w'); $_fh = fopen($filename, 'w');
fwrite($_fh, $dom_certs[$type]); fwrite($_fh, $dom_certs[$type]);
fclose($_fh); fclose($_fh);
if ($type == 'ssl_key_file') {
chmod($filename, 0600); chmod($filename, 0600);
} else {
chmod($filename, 0644);
}
} }
} }
// override corresponding array values // override corresponding array values

View File

@@ -98,8 +98,12 @@ class HttpConfigBase
'IP' => $ip, 'IP' => $ip,
'PORT' => $port, 'PORT' => $port,
'SCHEME' => ($is_ssl_vhost) ? 'https' : 'http', 'SCHEME' => ($is_ssl_vhost) ? 'https' : 'http',
'DOCROOT' => $domain['documentroot'] 'DOCROOT' => $domain['documentroot'],
'FPMSOCKET' => ''
); );
if ((int) Settings::Get('phpfpm.enabled') == 1 && isset($domain['fpm_socket']) && !empty($domain['fpm_socket'])) {
$templateVars['FPMSOCKET'] = $domain['fpm_socket'];
}
return \Froxlor\PhpHelper::replaceVariables($template, $templateVars); return \Froxlor\PhpHelper::replaceVariables($template, $templateVars);
} }

View File

@@ -6,6 +6,7 @@ use Froxlor\Settings;
use Froxlor\Database\Database; use Froxlor\Database\Database;
use Froxlor\PhpHelper; use Froxlor\PhpHelper;
use Froxlor\Domain\Domain; use Froxlor\Domain\Domain;
use Froxlor\FileDir;
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
@@ -27,6 +28,14 @@ use Froxlor\Domain\Domain;
class AcmeSh extends \Froxlor\Cron\FroxlorCron class AcmeSh extends \Froxlor\Cron\FroxlorCron
{ {
const ACME_PROVIDER = [
'letsencrypt' => "https://acme-v02.api.letsencrypt.org/directory",
'letsencrypt_test' => "https://acme-staging-v02.api.letsencrypt.org/directory",
'buypass' => "https://api.buypass.com/acme/directory",
'buypass_test' => "https://api.test4.buypass.no/acme/directory",
'zerossl' => "https://acme.zerossl.com/v2/DV90"
];
private static $apiserver = ""; private static $apiserver = "";
private static $acmesh = "/root/.acme.sh/acme.sh"; private static $acmesh = "/root/.acme.sh/acme.sh";
@@ -43,8 +52,6 @@ class AcmeSh extends \Froxlor\Cron\FroxlorCron
*/ */
private static $upddom_stmt = null; private static $upddom_stmt = null;
private static $do_update = true;
public static $no_inserttask = false; public static $no_inserttask = false;
/** /**
@@ -60,8 +67,11 @@ class AcmeSh extends \Froxlor\Cron\FroxlorCron
// Let's Encrypt cronjob is combined with regeneration of webserver configuration files. // Let's Encrypt cronjob is combined with regeneration of webserver configuration files.
// For debugging purposes you can use the --debug switch and the --force switch to run the cron manually. // For debugging purposes you can use the --debug switch and the --force switch to run the cron manually.
// check whether we MIGHT need to run although there is no task to regenerate config-files // check whether we MIGHT need to run although there is no task to regenerate config-files
$needRenew = self::issueDomains(); $issue_froxlor = self::issueFroxlorVhost();
if ($needRenew || self::issueFroxlorVhost()) { $issue_domains = self::issueDomains();
$renew_froxlor = self::renewFroxlorVhost();
$renew_domains = self::renewDomains(true);
if ($issue_froxlor || ! empty($issue_domains) || ! empty($renew_froxlor) || $renew_domains) {
// insert task to generate certificates and vhost-configs // insert task to generate certificates and vhost-configs
\Froxlor\System\Cronjob::inserttask(1); \Froxlor\System\Cronjob::inserttask(1);
} }
@@ -69,13 +79,15 @@ class AcmeSh extends \Froxlor\Cron\FroxlorCron
} }
// set server according to settings // set server according to settings
self::$apiserver = 'https://acme-' . (Settings::Get('system.letsencryptca') == 'testing' ? 'staging-' : '') . 'v0' . \Froxlor\Settings::Get('system.leapiversion') . '.api.letsencrypt.org/directory'; self::$apiserver = self::ACME_PROVIDER[Settings::Get('system.letsencryptca')];
// validate acme.sh installation // validate acme.sh installation
if (! self::checkInstall()) { if (! self::checkInstall()) {
return - 1; return - 1;
} }
self::checkUpgrade();
// flag for re-generation of vhost files // flag for re-generation of vhost files
$changedetected = 0; $changedetected = 0;
@@ -267,7 +279,7 @@ class AcmeSh extends \Froxlor\Cron\FroxlorCron
* @param int $domain_id * @param int $domain_id
* @param FroxlorLogger $cronlog * @param FroxlorLogger $cronlog
*/ */
private static function validateDns(&$domains = array(), $domain_id, &$cronlog) private static function validateDns(array &$domains, $domain_id, &$cronlog)
{ {
if (Settings::Get('system.le_domain_dnscheck') == '1' && ! empty($domains)) { if (Settings::Get('system.le_domain_dnscheck') == '1' && ! empty($domains)) {
$loop_domains = $domains; $loop_domains = $domains;
@@ -275,27 +287,28 @@ class AcmeSh extends \Froxlor\Cron\FroxlorCron
$our_ips = Domain::getIpsOfDomain($domain_id); $our_ips = Domain::getIpsOfDomain($domain_id);
foreach ($loop_domains as $idx => $domain) { foreach ($loop_domains as $idx => $domain) {
$cronlog->logAction(FroxlorLogger::CRON_ACTION, LOG_INFO, "Validating DNS of " . $domain); $cronlog->logAction(FroxlorLogger::CRON_ACTION, LOG_INFO, "Validating DNS of " . $domain);
// ips accordint to NS // ips according to NS
$domain_ips = PhpHelper::gethostbynamel6($domain); $domain_ips = PhpHelper::gethostbynamel6($domain);
if (count(array_intersect($our_ips, $domain_ips)) <= 0) { if ($domain_ips == false || count(array_intersect($our_ips, $domain_ips)) <= 0) {
// no common ips... // no common ips...
$cronlog->logAction(FroxlorLogger::CRON_ACTION, LOG_WARNING, "Skipping Let's Encrypt generation for " . $domain . " due to no system known IP address via DNS check"); $cronlog->logAction(FroxlorLogger::CRON_ACTION, LOG_WARNING, "Skipping Let's Encrypt generation for " . $domain . " due to no system known IP address via DNS check");
unset($domains[$idx]); unset($domains[$idx]);
// in order to avoid a cron-loop that tries to get a certificate every 5 minutes, we disable let's encrypt for this domain
$upd_stmt = Database::prepare("UPDATE `" . TABLE_PANEL_DOMAINS . "` SET `letsencrypt` = '0' WHERE `id` = :did");
Database::pexecute($upd_stmt, [
'did' => $domain_id
]);
$cronlog->logAction(FroxlorLogger::CRON_ACTION, LOG_WARNING, "Let's Encrypt deactivated for domain " . $domain);
} }
} }
} }
} }
private static function runAcmeSh($certrow = array(), $domains = array(), &$cronlog = null, $force = false) private static function runAcmeSh(array $certrow, array $domains, &$cronlog = null, $force = false)
{ {
if (! empty($domains)) { if (! empty($domains)) {
if (self::$do_update) { $acmesh_cmd = self::$acmesh . " --server " . self::$apiserver . " --issue -d " . implode(" -d ", $domains);
self::checkUpgrade();
self::$do_update = false;
}
$acmesh_cmd = self::$acmesh . " --auto-upgrade 0 --server " . self::$apiserver . " --issue -d " . implode(" -d ", $domains);
// challenge path // challenge path
$acmesh_cmd .= " -w " . Settings::Get('system.letsencryptchallengepath'); $acmesh_cmd .= " -w " . Settings::Get('system.letsencryptchallengepath');
if (Settings::Get('system.leecc') > 0) { if (Settings::Get('system.leecc') > 0) {
@@ -307,7 +320,7 @@ class AcmeSh extends \Froxlor\Cron\FroxlorCron
if (Settings::Get('system.letsencryptreuseold') != '1') { if (Settings::Get('system.letsencryptreuseold') != '1') {
$acmesh_cmd .= " --always-force-new-domain-key"; $acmesh_cmd .= " --always-force-new-domain-key";
} }
if (Settings::Get('system.letsencryptca') == 'testing') { if (Settings::Get('system.letsencryptca') == 'letsencrypt_test') {
$acmesh_cmd .= " --staging"; $acmesh_cmd .= " --staging";
} }
if ($force) { if ($force) {
@@ -400,8 +413,8 @@ class AcmeSh extends \Froxlor\Cron\FroxlorCron
"); ");
$froxlor_ssl = Database::pexecute_first($froxlor_ssl_settings_stmt); $froxlor_ssl = Database::pexecute_first($froxlor_ssl_settings_stmt);
// also check for possible existing certificate // also check for possible existing certificate
if ($froxlor_ssl || (! $froxlor_ssl && ! self::checkFsFilesAreNewer(Settings::Get('system.hostname'), date('Y-m-d H:i:s', 0)))) { if ($froxlor_ssl && self::checkFsFilesAreNewer(Settings::Get('system.hostname'), $froxlor_ssl['expirationdate'])) {
return ($froxlor_ssl ? $froxlor_ssl : true); return $froxlor_ssl;
} }
} }
return false; return false;
@@ -410,7 +423,7 @@ class AcmeSh extends \Froxlor\Cron\FroxlorCron
/** /**
* get a list of domains that have a lets encrypt certificate (possible renew) * get a list of domains that have a lets encrypt certificate (possible renew)
*/ */
private static function renewDomains() private static function renewDomains($check = false)
{ {
$certificates_stmt = Database::query(" $certificates_stmt = Database::query("
SELECT SELECT
@@ -438,6 +451,14 @@ class AcmeSh extends \Froxlor\Cron\FroxlorCron
"); ");
$renew_certs = $certificates_stmt->fetchAll(\PDO::FETCH_ASSOC); $renew_certs = $certificates_stmt->fetchAll(\PDO::FETCH_ASSOC);
if ($renew_certs) { if ($renew_certs) {
if ($check) {
foreach ($renew_certs as $cert) {
if (self::checkFsFilesAreNewer($cert['domain'], $cert['expirationdate'])) {
return true;
}
}
return false;
}
return $renew_certs; return $renew_certs;
} }
return array(); return array();
@@ -490,22 +511,42 @@ class AcmeSh extends \Froxlor\Cron\FroxlorCron
private static function checkFsFilesAreNewer($domain, $cert_date = 0) private static function checkFsFilesAreNewer($domain, $cert_date = 0)
{ {
$certificate_folder = dirname(self::$acmesh) . "/" . $domain; $certificate_folder = self::getWorkingDirFromEnv(strtolower($domain));
if (Settings::Get('system.leecc') > 0) { $ssl_file = \Froxlor\FileDir::makeCorrectFile($certificate_folder . '/' . strtolower($domain) . '.cer');
$certificate_folder .= "_ecc";
}
$certificate_folder = \Froxlor\FileDir::makeCorrectDir($certificate_folder);
$ssl_file = \Froxlor\FileDir::makeCorrectFile($certificate_folder . '/' . $domain . '.cer');
if (is_dir($certificate_folder) && file_exists($ssl_file) && is_readable($ssl_file)) { if (is_dir($certificate_folder) && file_exists($ssl_file) && is_readable($ssl_file)) {
$cert_data = openssl_x509_parse(file_get_contents($ssl_file)); $cert_data = openssl_x509_parse(file_get_contents($ssl_file));
if (strtotime($cert_data['validTo_time_t']) > strtotime($cert_date)) { if ($cert_data && $cert_data['validTo_time_t'] > strtotime($cert_date)) {
return true; return true;
} }
} }
return false; return false;
} }
public static function getWorkingDirFromEnv($domain = "", $forced_noecc = false)
{
if (Settings::Get('system.leecc') > 0 && ! $forced_noecc) {
$domain .= "_ecc";
}
$env_file = FileDir::makeCorrectFile(dirname(self::$acmesh) . '/acme.sh.env');
if (file_exists($env_file)) {
$output = [];
$cut = <<<EOC
cut -d'"' -f2
EOC;
exec('grep "LE_WORKING_DIR" ' . escapeshellarg($env_file) . ' | ' . $cut, $output);
if (is_array($output) && ! empty($output) && isset($output[0]) && ! empty($output[0])) {
return FileDir::makeCorrectDir($output[0] . "/" . $domain);
}
}
return FileDir::makeCorrectDir(dirname(self::$acmesh) . "/" . $domain);
}
public static function getAcmeSh()
{
return self::$acmesh;
}
/** /**
* get certificate files from filesystem and store in $return array * get certificate files from filesystem and store in $return array
* *
@@ -515,11 +556,10 @@ class AcmeSh extends \Froxlor\Cron\FroxlorCron
*/ */
private static function readCertificateToVar($domain, &$return, &$cronlog) private static function readCertificateToVar($domain, &$return, &$cronlog)
{ {
$certificate_folder = dirname(self::$acmesh) . "/" . $domain; $certificate_folder = self::getWorkingDirFromEnv($domain);
$certificate_folder_noecc = null; $certificate_folder_noecc = null;
if (Settings::Get('system.leecc') > 0) { if (Settings::Get('system.leecc') > 0) {
$certificate_folder_noecc = \Froxlor\FileDir::makeCorrectDir($certificate_folder); $certificate_folder_noecc = self::getWorkingDirFromEnv($domain, true);
$certificate_folder .= "_ecc";
} }
$certificate_folder = \Froxlor\FileDir::makeCorrectDir($certificate_folder); $certificate_folder = \Froxlor\FileDir::makeCorrectDir($certificate_folder);
@@ -578,7 +618,7 @@ class AcmeSh extends \Froxlor\Cron\FroxlorCron
*/ */
private static function checkUpgrade() private static function checkUpgrade()
{ {
$acmesh_result = \Froxlor\FileDir::safe_exec(self::$acmesh . " --upgrade"); $acmesh_result = \Froxlor\FileDir::safe_exec(self::$acmesh . " --upgrade --auto-upgrade 0");
// check for activated cron // check for activated cron
$acmesh_result2 = \Froxlor\FileDir::safe_exec(self::$acmesh . " --install-cronjob"); $acmesh_result2 = \Froxlor\FileDir::safe_exec(self::$acmesh . " --install-cronjob");
FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_INFO, "Checking for LetsEncrypt client upgrades before renewing certificates:\n" . implode("\n", $acmesh_result) . "\n" . implode("\n", $acmesh_result2)); FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_INFO, "Checking for LetsEncrypt client upgrades before renewing certificates:\n" . implode("\n", $acmesh_result) . "\n" . implode("\n", $acmesh_result2));

View File

@@ -188,7 +188,8 @@ class Lighttpd extends HttpConfigBase
$this->lighttpd_data[$vhost_filename] .= $this->processSpecialConfigTemplate($row_ipsandports['ssl_specialsettings'], $domain, $row_ipsandports['ip'], $row_ipsandports['port'], $row_ipsandports['ssl'] == '1') . "\n"; $this->lighttpd_data[$vhost_filename] .= $this->processSpecialConfigTemplate($row_ipsandports['ssl_specialsettings'], $domain, $row_ipsandports['ip'], $row_ipsandports['port'], $row_ipsandports['ssl'] == '1') . "\n";
} }
if ($row_ipsandports['ssl_cert_file'] == '') { // check for required fallback
if (($row_ipsandports['ssl_cert_file'] == '' || ! file_exists($row_ipsandports['ssl_cert_file'])) && (Settings::Get('system.le_froxlor_enabled') == '0' || $this->froxlorVhostHasLetsEncryptCert() == false)) {
$row_ipsandports['ssl_cert_file'] = Settings::Get('system.ssl_cert_file'); $row_ipsandports['ssl_cert_file'] = Settings::Get('system.ssl_cert_file');
if (! file_exists($row_ipsandports['ssl_cert_file'])) { if (! file_exists($row_ipsandports['ssl_cert_file'])) {
// explicitly disable ssl for this vhost // explicitly disable ssl for this vhost
@@ -363,7 +364,7 @@ class Lighttpd extends HttpConfigBase
return; return;
} }
protected function composePhpOptions($domain) protected function composePhpOptions(&$domain)
{ {
return; return;
} }
@@ -555,7 +556,7 @@ class Lighttpd extends HttpConfigBase
$ssl_settings = ''; $ssl_settings = '';
if ($ssl_vhost === true && $domain['ssl'] == '1' && (int) Settings::Get('system.use_ssl') == 1) { if ($ssl_vhost === true && $domain['ssl'] == '1' && (int) Settings::Get('system.use_ssl') == 1) {
if ($domain['ssl_cert_file'] == '') { if ($domain['ssl_cert_file'] == '' || ! file_exists($domain['ssl_cert_file'])) {
$domain['ssl_cert_file'] = Settings::Get('system.ssl_cert_file'); $domain['ssl_cert_file'] = Settings::Get('system.ssl_cert_file');
if (! file_exists($domain['ssl_cert_file'])) { if (! file_exists($domain['ssl_cert_file'])) {
// explicitly disable ssl for this vhost // explicitly disable ssl for this vhost
@@ -677,7 +678,7 @@ class Lighttpd extends HttpConfigBase
// After inserting the AWStats information, // After inserting the AWStats information,
// be sure to build the awstats conf file as well // be sure to build the awstats conf file as well
// and chown it using $awstats_params, #258 // and chown it using $awstats_params, #258
// Bug 960 + Bug 970 : Use full $domain instead of custom $awstats_params as following classes depend on the informations // Bug 960 + Bug 970 : Use full $domain instead of custom $awstats_params as following classes depend on the information
\Froxlor\Http\Statistics::createAWStatsConf(Settings::Get('system.logfiles_directory') . $domain['loginname'] . $speciallogfile . '-access.log', $domain['domain'], $alias . $server_alias, $domain['customerroot'], $domain); \Froxlor\Http\Statistics::createAWStatsConf(Settings::Get('system.logfiles_directory') . $domain['loginname'] . $speciallogfile . '-access.log', $domain['domain'], $alias . $server_alias, $domain['customerroot'], $domain);
} }
} }

View File

@@ -22,7 +22,7 @@ use Froxlor\Cron\Http\Php\PhpInterface;
class LighttpdFcgi extends Lighttpd class LighttpdFcgi extends Lighttpd
{ {
protected function composePhpOptions($domain) protected function composePhpOptions(&$domain)
{ {
$php_options_text = ''; $php_options_text = '';
@@ -32,10 +32,11 @@ class LighttpdFcgi extends Lighttpd
// vhost data for php-fpm // vhost data for php-fpm
if ((int) Settings::Get('phpfpm.enabled') == 1) { if ((int) Settings::Get('phpfpm.enabled') == 1) {
$domain['fpm_socket'] = $php->getInterface()->getSocketFile();
$php_options_text = ' fastcgi.server = ( ' . "\n"; $php_options_text = ' fastcgi.server = ( ' . "\n";
$php_options_text .= "\t" . '".php" => (' . "\n"; $php_options_text .= "\t" . '".php" => (' . "\n";
$php_options_text .= "\t\t" . '"localhost" => (' . "\n"; $php_options_text .= "\t\t" . '"localhost" => (' . "\n";
$php_options_text .= "\t\t" . '"socket" => "' . $php->getInterface()->getSocketFile() . '",' . "\n"; $php_options_text .= "\t\t" . '"socket" => "' . $domain['fpm_socket'] . '",' . "\n";
$php_options_text .= "\t\t" . '"check-local" => "enable",' . "\n"; $php_options_text .= "\t\t" . '"check-local" => "enable",' . "\n";
$php_options_text .= "\t\t" . '"disable-time" => 1' . "\n"; $php_options_text .= "\t\t" . '"disable-time" => 1' . "\n";
$php_options_text .= "\t" . ')' . "\n"; $php_options_text .= "\t" . ')' . "\n";

View File

@@ -155,7 +155,8 @@ class Nginx extends HttpConfigBase
// we know whether it's an ssl vhost or not // we know whether it's an ssl vhost or not
$ssl_vhost = false; $ssl_vhost = false;
if ($row_ipsandports['ssl'] == '1') { if ($row_ipsandports['ssl'] == '1') {
if ($row_ipsandports['ssl_cert_file'] == '') { // check for required fallback
if (($row_ipsandports['ssl_cert_file'] == '' || ! file_exists($row_ipsandports['ssl_cert_file'])) && (Settings::Get('system.le_froxlor_enabled') == '0' || $this->froxlorVhostHasLetsEncryptCert() == false)) {
$row_ipsandports['ssl_cert_file'] = Settings::Get('system.ssl_cert_file'); $row_ipsandports['ssl_cert_file'] = Settings::Get('system.ssl_cert_file');
if (! file_exists($row_ipsandports['ssl_cert_file'])) { if (! file_exists($row_ipsandports['ssl_cert_file'])) {
// explicitly disable ssl for this vhost // explicitly disable ssl for this vhost
@@ -165,6 +166,11 @@ class Nginx extends HttpConfigBase
} }
if ($row_ipsandports['ssl_key_file'] == '') { if ($row_ipsandports['ssl_key_file'] == '') {
$row_ipsandports['ssl_key_file'] = Settings::Get('system.ssl_key_file'); $row_ipsandports['ssl_key_file'] = Settings::Get('system.ssl_key_file');
if (! file_exists($row_ipsandports['ssl_key_file'])) {
// explicitly disable ssl for this vhost
$row_ipsandports['ssl_cert_file'] = "";
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(\Froxlor\FroxlorLogger::CRON_ACTION, LOG_DEBUG, 'System certificate key-file "' . Settings::Get('system.ssl_key_file') . '" does not seem to exist. Disabling SSL-vhost for "' . Settings::Get('system.hostname') . '"');
}
} }
if ($row_ipsandports['ssl_ca_file'] == '') { if ($row_ipsandports['ssl_ca_file'] == '') {
$row_ipsandports['ssl_ca_file'] = Settings::Get('system.ssl_ca_file'); $row_ipsandports['ssl_ca_file'] = Settings::Get('system.ssl_ca_file');
@@ -659,7 +665,7 @@ class Nginx extends HttpConfigBase
{ {
$sslsettings = ''; $sslsettings = '';
if ($domain_or_ip['ssl_cert_file'] == '') { if ($domain_or_ip['ssl_cert_file'] == '' || ! file_exists($domain_or_ip['ssl_cert_file'])) {
$domain_or_ip['ssl_cert_file'] = Settings::Get('system.ssl_cert_file'); $domain_or_ip['ssl_cert_file'] = Settings::Get('system.ssl_cert_file');
if (! file_exists($domain_or_ip['ssl_cert_file'])) { if (! file_exists($domain_or_ip['ssl_cert_file'])) {
// explicitly disable ssl for this vhost // explicitly disable ssl for this vhost
@@ -668,8 +674,15 @@ class Nginx extends HttpConfigBase
} }
} }
if ($domain_or_ip['ssl_key_file'] == '') { if ($domain_or_ip['ssl_key_file'] == '' || ! file_exists($domain_or_ip['ssl_key_file'])) {
// use fallback
$domain_or_ip['ssl_key_file'] = Settings::Get('system.ssl_key_file'); $domain_or_ip['ssl_key_file'] = Settings::Get('system.ssl_key_file');
// check whether it exists
if (! file_exists($domain_or_ip['ssl_key_file'])) {
// explicitly disable ssl for this vhost
$domain_or_ip['ssl_cert_file'] = "";
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(\Froxlor\FroxlorLogger::CRON_ACTION, LOG_DEBUG, 'System certificate key-file "' . Settings::Get('system.ssl_key_file') . '" does not seem to exist. Disabling SSL-vhost for "' . $domain_or_ip['domain'] . '"');
}
} }
if ($domain_or_ip['ssl_ca_file'] == '') { if ($domain_or_ip['ssl_ca_file'] == '') {
@@ -901,7 +914,6 @@ class Nginx extends HttpConfigBase
FROM `" . TABLE_PANEL_HTPASSWDS . "` AS a FROM `" . TABLE_PANEL_HTPASSWDS . "` AS a
JOIN `" . TABLE_PANEL_DOMAINS . "` AS b USING (`customerid`) JOIN `" . TABLE_PANEL_DOMAINS . "` AS b USING (`customerid`)
WHERE b.customerid = :customerid AND b.domain = :domain WHERE b.customerid = :customerid AND b.domain = :domain
AND path LIKE CONCAT(b.documentroot, '%')
"); ");
Database::pexecute($result_stmt, array( Database::pexecute($result_stmt, array(
'customerid' => $domain['customerid'], 'customerid' => $domain['customerid'],
@@ -958,7 +970,7 @@ class Nginx extends HttpConfigBase
return $returnval; return $returnval;
} }
protected function composePhpOptions($domain, $ssl_vhost = false) protected function composePhpOptions(&$domain, $ssl_vhost = false)
{ {
$phpopts = ''; $phpopts = '';
if ($domain['phpenabled_customer'] == 1 && $domain['phpenabled_vhost'] == '1') { if ($domain['phpenabled_customer'] == 1 && $domain['phpenabled_vhost'] == '1') {
@@ -1041,10 +1053,10 @@ class Nginx extends HttpConfigBase
if (Settings::Get('system.awstats_enabled') == '1') { if (Settings::Get('system.awstats_enabled') == '1') {
// awstats // awstats
$stats_text .= "\t" . 'location /awstats {' . "\n"; $stats_text .= "\t" . 'location ^~ /awstats/ {' . "\n";
} else { } else {
// webalizer // webalizer
$stats_text .= "\t" . 'location /webalizer {' . "\n"; $stats_text .= "\t" . 'location ^~ /webalizer {' . "\n";
} }
$stats_text .= "\t\t" . 'alias ' . $alias_dir . ';' . "\n"; $stats_text .= "\t\t" . 'alias ' . $alias_dir . ';' . "\n";
@@ -1141,7 +1153,7 @@ class Nginx extends HttpConfigBase
// After inserting the AWStats information, // After inserting the AWStats information,
// be sure to build the awstats conf file as well // be sure to build the awstats conf file as well
// and chown it using $awstats_params, #258 // and chown it using $awstats_params, #258
// Bug 960 + Bug 970 : Use full $domain instead of custom $awstats_params as following classes depend on the informations // Bug 960 + Bug 970 : Use full $domain instead of custom $awstats_params as following classes depend on the information
\Froxlor\Http\Statistics::createAWStatsConf(Settings::Get('system.logfiles_directory') . $domain['loginname'] . $speciallogfile . '-access.log', $domain['domain'], $alias . $server_alias, $domain['customerroot'], $domain); \Froxlor\Http\Statistics::createAWStatsConf(Settings::Get('system.logfiles_directory') . $domain['loginname'] . $speciallogfile . '-access.log', $domain['domain'], $alias . $server_alias, $domain['customerroot'], $domain);
} }
} }

View File

@@ -22,7 +22,7 @@ use Froxlor\Cron\Http\Php\PhpInterface;
class NginxFcgi extends Nginx class NginxFcgi extends Nginx
{ {
protected function composePhpOptions($domain, $ssl_vhost = false) protected function composePhpOptions(&$domain, $ssl_vhost = false)
{ {
$php_options_text = ''; $php_options_text = '';
@@ -43,7 +43,8 @@ class NginxFcgi extends Nginx
if ($domain['ssl'] == '1' && $ssl_vhost) { if ($domain['ssl'] == '1' && $ssl_vhost) {
$php_options_text .= "\t\t" . 'fastcgi_param HTTPS on;' . "\n"; $php_options_text .= "\t\t" . 'fastcgi_param HTTPS on;' . "\n";
} }
$php_options_text .= "\t\t" . 'fastcgi_pass unix:' . $php->getInterface()->getSocketFile() . ";\n"; $domain['fpm_socket'] = $php->getInterface()->getSocketFile();
$php_options_text .= "\t\t" . 'fastcgi_pass unix:' . $domain['fpm_socket'] . ";\n";
$php_options_text .= "\t\t" . 'fastcgi_index index.php;' . "\n"; $php_options_text .= "\t\t" . 'fastcgi_index index.php;' . "\n";
$php_options_text .= "\t}\n\n"; $php_options_text .= "\t}\n\n";

View File

@@ -94,7 +94,7 @@ class Fcgid
// Set Binary // Set Binary
$starter_file .= "exec " . $phpconfig['binary'] . " -c " . escapeshellarg($this->getConfigDir()) . "\n"; $starter_file .= "exec " . $phpconfig['binary'] . " -c " . escapeshellarg($this->getConfigDir()) . "\n";
// remove +i attibute, so starter can be overwritten // remove +i attribute, so starter can be overwritten
if (file_exists($this->getStarterFile())) { if (file_exists($this->getStarterFile())) {
\Froxlor\FileDir::removeImmutable($this->getStarterFile()); \Froxlor\FileDir::removeImmutable($this->getStarterFile());
} }

View File

@@ -218,7 +218,7 @@ class Fpm
$openbasedir .= $_phpappendopenbasedir; $openbasedir .= $_phpappendopenbasedir;
} }
} }
$fpm_config .= 'php_admin_value[session.save_path] = ' . \Froxlor\FileDir::makeCorrectDir(Settings::Get('phpfpm.tmpdir') . '/' . $this->domain['loginname'] . '/') . "\n";
$fpm_config .= 'php_admin_value[upload_tmp_dir] = ' . \Froxlor\FileDir::makeCorrectDir(Settings::Get('phpfpm.tmpdir') . '/' . $this->domain['loginname'] . '/') . "\n"; $fpm_config .= 'php_admin_value[upload_tmp_dir] = ' . \Froxlor\FileDir::makeCorrectDir(Settings::Get('phpfpm.tmpdir') . '/' . $this->domain['loginname'] . '/') . "\n";
$admin = $this->getAdminData($this->domain['adminid']); $admin = $this->getAdminData($this->domain['adminid']);
@@ -261,6 +261,11 @@ class Fpm
$fpm_config .= 'php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f ' . $this->domain['email'] . "\n"; $fpm_config .= 'php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f ' . $this->domain['email'] . "\n";
} }
// check for session.save_path, whether it has been specified by the user, if not, set a default
if (strpos($fpm_config, 'php_value[session.save_path]') === false && strpos($fpm_config, 'php_admin_value[session.save_path]') === false) {
$fpm_config .= 'php_admin_value[session.save_path] = ' . $this->getTempDir() . "\n";
}
// append custom phpfpm configuration // append custom phpfpm configuration
if (! empty($fpm_custom_config)) { if (! empty($fpm_custom_config)) {
$fpm_config .= "\n; Custom Configuration\n"; $fpm_config .= "\n; Custom Configuration\n";

View File

@@ -108,6 +108,11 @@ class PhpInterface
$this->_php_configs_cache[$php_config_id]['fpm_settings'] = Database::pexecute_first($stmt, array( $this->_php_configs_cache[$php_config_id]['fpm_settings'] = Database::pexecute_first($stmt, array(
'id' => $this->_php_configs_cache[$php_config_id]['fpmsettingid'] 'id' => $this->_php_configs_cache[$php_config_id]['fpmsettingid']
)); ));
// override fpm daemon settings if set in php-config
if ($this->_php_configs_cache[$php_config_id]['override_fpmconfig'] == 1) {
$this->_php_configs_cache[$php_config_id]['fpm_settings']['limit_extensions'] = $this->_php_configs_cache[$php_config_id]['limit_extensions'];
$this->_php_configs_cache[$php_config_id]['fpm_settings']['idle_timeout'] = $this->_php_configs_cache[$php_config_id]['idle_timeout'];
}
} }
} }

View File

@@ -2,6 +2,7 @@
namespace Froxlor\Cron\System; namespace Froxlor\Cron\System;
use Froxlor\Database\Database; use Froxlor\Database\Database;
use Froxlor\Settings;
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
@@ -24,13 +25,14 @@ class Extrausers
{ {
// passwd // passwd
$passwd = '/var/lib/extrausers/passwd'; $passwd = '/var/lib/extrausers/passwd';
$sql = "SELECT customerid,username,'x' as password,uid,gid,'Froxlor User' as comment,homedir,shell, login_enabled FROM ftp_users ORDER BY uid ASC"; $sql = "SELECT customerid,username,'x' as password,uid,gid,'Froxlor User' as comment,homedir,shell, login_enabled FROM ftp_users ORDER BY uid, LENGTH(username) ASC";
self::generateFile($passwd, $sql, $cronlog); $users_list = [];
self::generateFile($passwd, $sql, $cronlog, $users_list);
// group // group
$group = '/var/lib/extrausers/group'; $group = '/var/lib/extrausers/group';
$sql = "SELECT groupname,'x' as password,gid,members FROM ftp_groups ORDER BY gid ASC"; $sql = "SELECT groupname,'x' as password,gid,members FROM ftp_groups ORDER BY gid ASC";
self::generateFile($group, $sql, $cronlog); self::generateFile($group, $sql, $cronlog, $users_list);
// shadow // shadow
$shadow = '/var/lib/extrausers/shadow'; $shadow = '/var/lib/extrausers/shadow';
@@ -44,7 +46,7 @@ class Extrausers
@chmod('/var/lib/extrausers/shadow', 0640); @chmod('/var/lib/extrausers/shadow', 0640);
} }
private static function generateFile($file, $query, &$cronlog) private static function generateFile($file, $query, &$cronlog, &$result_list = null)
{ {
$type = basename($file); $type = basename($file);
$cronlog->logAction(\Froxlor\FroxlorLogger::CRON_ACTION, LOG_NOTICE, 'Creating ' . $type . ' file'); $cronlog->logAction(\Froxlor\FroxlorLogger::CRON_ACTION, LOG_NOTICE, 'Creating ' . $type . ' file');
@@ -74,6 +76,9 @@ class Extrausers
$u['comment'] = 'Locked Froxlor User'; $u['comment'] = 'Locked Froxlor User';
} }
$line = $u['username'] . ':' . $u['password'] . ':' . $u['uid'] . ':' . $u['gid'] . ':' . $u['comment'] . ':' . $u['homedir'] . ':' . $u['shell'] . PHP_EOL; $line = $u['username'] . ':' . $u['password'] . ':' . $u['uid'] . ':' . $u['gid'] . ':' . $u['comment'] . ':' . $u['homedir'] . ':' . $u['shell'] . PHP_EOL;
if (is_array($result_list)) {
$result_list[] = $u['username'];
}
break; break;
case 'group': case 'group':
$line = $u['groupname'] . ':' . $u['password'] . ':' . $u['gid'] . ':' . $u['members'] . PHP_EOL; $line = $u['groupname'] . ':' . $u['password'] . ':' . $u['gid'] . ':' . $u['members'] . PHP_EOL;
@@ -84,6 +89,19 @@ class Extrausers
} }
$data_content .= $line; $data_content .= $line;
} }
// check for local group to generate
if ($type == 'group' && Settings::Get('system.froxlorusergroup') != '') {
$guid = intval(Settings::Get('system.froxlorusergroup_gid'));
if (empty($guid)) {
$guid = intval(Settings::Get('system.lastguid')) + 1;
Settings::Set('system.lastguid', $guid, true);
Settings::Set('system.froxlorusergroup_gid', $guid, true);
}
$line = Settings::Get('system.froxlorusergroup') . ':x:' . $guid . ':' . implode(',', $result_list) . PHP_EOL;
$data_content .= $line;
}
if (file_put_contents($file, $data_content) !== false) { if (file_put_contents($file, $data_content) !== false) {
$cronlog->logAction(\Froxlor\FroxlorLogger::CRON_ACTION, LOG_NOTICE, 'Succesfully wrote ' . $type . ' file'); $cronlog->logAction(\Froxlor\FroxlorLogger::CRON_ACTION, LOG_NOTICE, 'Succesfully wrote ' . $type . ' file');
} else { } else {

View File

@@ -111,11 +111,11 @@ class ReportsCron extends \Froxlor\Cron\FroxlorCron
'varname' => 'trafficmaxpercent_subject' 'varname' => 'trafficmaxpercent_subject'
); );
$result2 = Database::pexecute_first($result2_stmt, $result2_data); $result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_subject = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['subject']), $replace_arr)); $mail_subject = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['subject']), $replace_arr));
$result2_data['varname'] = 'trafficmaxpercent_mailbody'; $result2_data['varname'] = 'trafficmaxpercent_mailbody';
$result2 = Database::pexecute_first($result2_stmt, $result2_data); $result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_body = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['mailbody']), $replace_arr)); $mail_body = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['mailbody']), $replace_arr));
$_mailerror = false; $_mailerror = false;
$mailerr_msg = ""; $mailerr_msg = "";
@@ -217,11 +217,11 @@ class ReportsCron extends \Froxlor\Cron\FroxlorCron
'varname' => 'trafficmaxpercent_subject' 'varname' => 'trafficmaxpercent_subject'
); );
$result2 = Database::pexecute_first($result2_stmt, $result2_data); $result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_subject = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['subject']), $replace_arr)); $mail_subject = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['subject']), $replace_arr));
$result2_data['varname'] = 'trafficmaxpercent_mailbody'; $result2_data['varname'] = 'trafficmaxpercent_mailbody';
$result2 = Database::pexecute_first($result2_stmt, $result2_data); $result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_body = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['mailbody']), $replace_arr)); $mail_body = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['mailbody']), $replace_arr));
$_mailerror = false; $_mailerror = false;
$mailerr_msg = ""; $mailerr_msg = "";
@@ -424,11 +424,11 @@ class ReportsCron extends \Froxlor\Cron\FroxlorCron
'varname' => 'diskmaxpercent_subject' 'varname' => 'diskmaxpercent_subject'
); );
$result2 = Database::pexecute_first($result2_stmt, $result2_data); $result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_subject = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['subject']), $replace_arr)); $mail_subject = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['subject']), $replace_arr));
$result2_data['varname'] = 'diskmaxpercent_mailbody'; $result2_data['varname'] = 'diskmaxpercent_mailbody';
$result2 = Database::pexecute_first($result2_stmt, $result2_data); $result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_body = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['mailbody']), $replace_arr)); $mail_body = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['mailbody']), $replace_arr));
$_mailerror = false; $_mailerror = false;
$mailerr_msg = ""; $mailerr_msg = "";
@@ -521,11 +521,11 @@ class ReportsCron extends \Froxlor\Cron\FroxlorCron
'varname' => 'diskmaxpercent_subject' 'varname' => 'diskmaxpercent_subject'
); );
$result2 = Database::pexecute_first($result2_stmt, $result2_data); $result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_subject = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['subject']), $replace_arr)); $mail_subject = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['subject']), $replace_arr));
$result2_data['varname'] = 'diskmaxpercent_mailbody'; $result2_data['varname'] = 'diskmaxpercent_mailbody';
$result2 = Database::pexecute_first($result2_stmt, $result2_data); $result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_body = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['mailbody']), $replace_arr)); $mail_body = html_entity_decode(\Froxlor\PhpHelper::replaceVariables((($result2 !== false && $result2['value'] != '') ? $result2['value'] : $lng['mails']['diskmaxpercent']['mailbody']), $replace_arr));
$_mailerror = false; $_mailerror = false;
$mailerr_msg = ""; $mailerr_msg = "";

View File

@@ -69,7 +69,7 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
} }
/** /**
* TRAFFIC AND DISKUSAGE MESSURE * TRAFFIC AND DISKUSAGE MEASURE
*/ */
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(\Froxlor\FroxlorLogger::CRON_ACTION, LOG_INFO, 'Traffic run started...'); \Froxlor\FroxlorLogger::getInstanceOf()->logAction(\Froxlor\FroxlorLogger::CRON_ACTION, LOG_INFO, 'Traffic run started...');
$admin_traffic = array(); $admin_traffic = array();
@@ -163,6 +163,13 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
$result_stmt = Database::query("SELECT * FROM `" . TABLE_PANEL_CUSTOMERS . "` ORDER BY `customerid` ASC"); $result_stmt = Database::query("SELECT * FROM `" . TABLE_PANEL_CUSTOMERS . "` ORDER BY `customerid` ASC");
$currentDate = date("Y-m-d");
$current_stamp = time();
$current_year = date('Y', $current_stamp);
$current_month = date('m', $current_stamp);
$current_day = date('d', $current_stamp);
while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) { while ($row = $result_stmt->fetch(\PDO::FETCH_ASSOC)) {
/** /**
* HTTP-Traffic * HTTP-Traffic
@@ -208,7 +215,7 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
// will iterate through all customer-domains and the awstats-configs // will iterate through all customer-domains and the awstats-configs
// know the logfile-name, #246 // know the logfile-name, #246
if (Settings::Get('system.awstats_enabled') == '1') { if (Settings::Get('system.awstats_enabled') == '1') {
$httptraffic += floatval(self::callAwstatsGetTraffic($row['customerid'], $row['documentroot'] . '/awstats/', $domainlist[$row['customerid']])); $httptraffic += floatval(self::callAwstatsGetTraffic($row['customerid'], $row['documentroot'] . '/awstats/', $domainlist[$row['customerid']], $current_stamp));
} else { } else {
$httptraffic += floatval(self::callWebalizerGetTraffic($row['loginname'], $row['documentroot'] . '/webalizer/', $caption, $domainlist[$row['customerid']])); $httptraffic += floatval(self::callWebalizerGetTraffic($row['loginname'], $row['documentroot'] . '/webalizer/', $caption, $domainlist[$row['customerid']]));
} }
@@ -250,8 +257,6 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
if (Settings::Get("system.mailtraffic_enabled")) { if (Settings::Get("system.mailtraffic_enabled")) {
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(\Froxlor\FroxlorLogger::CRON_ACTION, LOG_INFO, 'mail traffic usage for ' . $row['loginname'] . " started..."); \Froxlor\FroxlorLogger::getInstanceOf()->logAction(\Froxlor\FroxlorLogger::CRON_ACTION, LOG_INFO, 'mail traffic usage for ' . $row['loginname'] . " started...");
$currentDate = date("Y-m-d");
$domains_stmt = Database::prepare("SELECT domain FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `customerid` = :cid"); $domains_stmt = Database::prepare("SELECT domain FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `customerid` = :cid");
Database::pexecute($domains_stmt, array( Database::pexecute($domains_stmt, array(
"cid" => $row['customerid'] "cid" => $row['customerid']
@@ -312,10 +317,10 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
$ins_data = array( $ins_data = array(
'customerid' => $row['customerid'], 'customerid' => $row['customerid'],
'year' => date('Y', time()), 'year' => $current_year,
'month' => date('m', time()), 'month' => $current_month,
'day' => date('d', time()), 'day' => $current_day,
'stamp' => time(), 'stamp' => $current_stamp,
'http' => $current_traffic['http'], 'http' => $current_traffic['http'],
'ftp_up' => $current_traffic['ftp_up'], 'ftp_up' => $current_traffic['ftp_up'],
'ftp_down' => $current_traffic['ftp_down'], 'ftp_down' => $current_traffic['ftp_down'],
@@ -340,8 +345,8 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
FROM `" . TABLE_PANEL_TRAFFIC . "` WHERE `year` = :year AND `month` = :month AND `customerid` = :customerid FROM `" . TABLE_PANEL_TRAFFIC . "` WHERE `year` = :year AND `month` = :month AND `customerid` = :customerid
"); ");
$sum_month_traffic = Database::pexecute_first($sum_month_traffic_stmt, array( $sum_month_traffic = Database::pexecute_first($sum_month_traffic_stmt, array(
'year' => date('Y', time()), 'year' => $current_year,
'month' => date('m', time()), 'month' => $current_month,
'customerid' => $row['customerid'] 'customerid' => $row['customerid']
)); ));
$sum_month_traffic['all'] = $sum_month_traffic['http'] + $sum_month_traffic['ftp_up'] + $sum_month_traffic['ftp_down'] + $sum_month_traffic['mail']; $sum_month_traffic['all'] = $sum_month_traffic['http'] + $sum_month_traffic['ftp_up'] + $sum_month_traffic['ftp_down'] + $sum_month_traffic['mail'];
@@ -425,10 +430,10 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
$ins_data = array( $ins_data = array(
'customerid' => $row['customerid'], 'customerid' => $row['customerid'],
'year' => date('Y', time()), 'year' => $current_year,
'month' => date('m', time()), 'month' => $current_month,
'day' => date('d', time()), 'day' => $current_day,
'stamp' => time(), 'stamp' => $current_stamp,
'webspace' => $current_diskspace['webspace'], 'webspace' => $current_diskspace['webspace'],
'mail' => $current_diskspace['mail'], 'mail' => $current_diskspace['mail'],
'mysql' => $current_diskspace['mysql'] 'mysql' => $current_diskspace['mysql']
@@ -534,10 +539,10 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
$ins_data = array( $ins_data = array(
'adminid' => $row['adminid'], 'adminid' => $row['adminid'],
'year' => date('Y', time()), 'year' => $current_year,
'month' => date('m', time()), 'month' => $current_month,
'day' => date('d', time()), 'day' => $current_day,
'stamp' => time(), 'stamp' => $current_stamp,
'http' => $admin_traffic[$row['adminid']]['http'], 'http' => $admin_traffic[$row['adminid']]['http'],
'ftp_up' => $admin_traffic[$row['adminid']]['ftp_up'], 'ftp_up' => $admin_traffic[$row['adminid']]['ftp_up'],
'ftp_down' => $admin_traffic[$row['adminid']]['ftp_down'], 'ftp_down' => $admin_traffic[$row['adminid']]['ftp_down'],
@@ -570,29 +575,6 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
} }
if (isset($admin_diskspace[$row['adminid']])) { if (isset($admin_diskspace[$row['adminid']])) {
$ins_data = array(
'adminid' => $row['adminid'],
'year' => date('Y', time()),
'month' => date('m', time()),
'day' => date('d', time()),
'stamp' => time(),
'webspace' => $admin_diskspace[$row['adminid']]['webspace'],
'mail' => $admin_diskspace[$row['adminid']]['mail'],
'mysql' => $admin_diskspace[$row['adminid']]['mysql']
);
$ins_stmt = Database::prepare("
INSERT INTO `" . TABLE_PANEL_DISKSPACE_ADMINS . "` SET
`adminid` = :adminid,
`year` = :year,
`month` = :month,
`day` = :day,
`stamp` = :stamp,
`webspace` = :webspace,
`mail` = :mail,
`mysql` = :mysql
");
$upd_data = array( $upd_data = array(
'diskspace' => $admin_diskspace[$row['adminid']]['all'], 'diskspace' => $admin_diskspace[$row['adminid']]['all'],
'adminid' => $row['adminid'] 'adminid' => $row['adminid']
@@ -757,7 +739,7 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
return; return;
} }
private static function callAwstatsGetTraffic($customerid, $outputdir, $usersdomainlist) private static function callAwstatsGetTraffic($customerid, $outputdir, $usersdomainlist, $current_stamp)
{ {
$returnval = 0; $returnval = 0;
@@ -789,8 +771,8 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
"); ");
$result_data = array( $result_data = array(
'customerid' => $customerid, 'customerid' => $customerid,
'year' => date('Y', time()), 'year' => date('Y', $current_stamp),
'month' => date('m', time()) 'month' => date('m', $current_stamp)
); );
$result = Database::pexecute_first($result_stmt, $result_data); $result = Database::pexecute_first($result_stmt, $result_data);

View File

@@ -30,7 +30,7 @@ class Customer
* *
* @return string customers loginname * @return string customers loginname
*/ */
public function getLoginNameByUid($uid = null) public static function getLoginNameByUid($uid = null)
{ {
$result_stmt = Database::prepare(" $result_stmt = Database::prepare("
SELECT `loginname` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `guid` = :guid SELECT `loginname` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `guid` = :guid

View File

@@ -165,7 +165,7 @@ class Database
} }
/** /**
* returns the sql-access data as array using indeces * returns the sql-access data as array using indices
* 'user', 'passwd' and 'host'. * 'user', 'passwd' and 'host'.
* Returns false if not enabled * Returns false if not enabled
* *
@@ -279,6 +279,8 @@ class Database
$host = $sql_root[self::$dbserver]['host']; $host = $sql_root[self::$dbserver]['host'];
$socket = isset($sql_root[self::$dbserver]['socket']) ? $sql_root[self::$dbserver]['socket'] : null; $socket = isset($sql_root[self::$dbserver]['socket']) ? $sql_root[self::$dbserver]['socket'] : null;
$port = isset($sql_root[self::$dbserver]['port']) ? $sql_root[self::$dbserver]['port'] : '3306'; $port = isset($sql_root[self::$dbserver]['port']) ? $sql_root[self::$dbserver]['port'] : '3306';
$sslCAFile = $sql_root[self::$dbserver]['ssl']['caFile'] ?? "";
$sslVerifyServerCertificate = $sql_root[self::$dbserver]['ssl']['verifyServerCertificate'] ?? false;
} else { } else {
$caption = 'localhost'; $caption = 'localhost';
$user = $sql["user"]; $user = $sql["user"];
@@ -286,6 +288,8 @@ class Database
$host = $sql["host"]; $host = $sql["host"];
$socket = isset($sql['socket']) ? $sql['socket'] : null; $socket = isset($sql['socket']) ? $sql['socket'] : null;
$port = isset($sql['port']) ? $sql['port'] : '3306'; $port = isset($sql['port']) ? $sql['port'] : '3306';
$sslCAFile = $sql['ssl']['caFile'] ?? "";
$sslVerifyServerCertificate = $sql['ssl']['verifyServerCertificate'] ?? false;
} }
// save sql-access-data if needed // save sql-access-data if needed
@@ -297,7 +301,9 @@ class Database
'port' => $port, 'port' => $port,
'socket' => $socket, 'socket' => $socket,
'db' => $sql["db"], 'db' => $sql["db"],
'caption' => $caption 'caption' => $caption,
'ssl_ca_file' => $sslCAFile,
'ssl_verify_server_certificate' => $sslVerifyServerCertificate
); );
} }
@@ -321,6 +327,11 @@ class Database
} else { } else {
$dbconf["dsn"]['host'] = $host; $dbconf["dsn"]['host'] = $host;
$dbconf["dsn"]['port'] = $port; $dbconf["dsn"]['port'] = $port;
if (!empty(self::$sqldata['ssl_ca_file'])) {
$options[\PDO::MYSQL_ATTR_SSL_CA] = self::$sqldata['ssl_ca_file'];
$options[\PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT] = (bool) self::$sqldata['ssl_verify_server_certificate'];
}
} }
self::$dbname = $sql["db"]; self::$dbname = $sql["db"];

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