auto-format all files; add table-definitions to test-bootstrap file

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2018-12-21 12:24:07 +01:00
parent 1ff784198c
commit 97b5439c0d
209 changed files with 6840 additions and 4534 deletions

View File

@@ -2,7 +2,7 @@
namespace Froxlor\Cron\Http;
use Froxlor\Database\Database;
use \Froxlor\Settings;
use Froxlor\Settings;
use Froxlor\Cron\Http\Php\Fpm;
use Froxlor\Cron\Http\Php\PhpInterface;

View File

@@ -2,7 +2,7 @@
namespace Froxlor\Cron\Http;
use Froxlor\Database\Database;
use \Froxlor\Settings;
use Froxlor\Settings;
use Froxlor\Cron\Http\Php\PhpInterface;
/**
@@ -14,27 +14,25 @@ use Froxlor\Cron\Http\Php\PhpInterface;
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Cron
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Cron
*
*/
class ApacheFcgi extends Apache
{
protected function composePhpOptions($domain, $ssl_vhost = false)
{
$php_options_text = '';
if($domain['phpenabled_customer'] == 1 && $domain['phpenabled_vhost'] == '1')
{
if ($domain['phpenabled_customer'] == 1 && $domain['phpenabled_vhost'] == '1') {
$php = new PhpInterface($domain);
$phpconfig = $php->getPhpConfig((int)$domain['phpsettingid']);
$phpconfig = $php->getPhpConfig((int) $domain['phpsettingid']);
if((int)Settings::Get('phpfpm.enabled') == 1)
{
if ((int) Settings::Get('phpfpm.enabled') == 1) {
$srvName = 'fpm.external';
if ($domain['ssl'] == 1 && $ssl_vhost) {
$srvName = 'ssl-fpm.external';
@@ -42,116 +40,107 @@ class ApacheFcgi extends Apache
// #1317 - perl is executed via apache and therefore, when using fpm, does not know the user
// which perl is supposed to run as, hence the need for Suexec need
if (customerHasPerlEnabled($domain['customerid'])) {
$php_options_text.= ' SuexecUserGroup "' . $domain['loginname'] . '" "' . $domain['loginname'] . '"' . "\n";
$php_options_text .= ' SuexecUserGroup "' . $domain['loginname'] . '" "' . $domain['loginname'] . '"' . "\n";
}
// 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'];
$extensions = explode(" ", $filesmatch);
$filesmatch = "";
foreach ($extensions as $ext) {
$filesmatch .= substr($ext, 1).'|';
$filesmatch .= substr($ext, 1) . '|';
}
// start block, cut off last pipe and close block
$filesmatch = '('.str_replace(".", "\.", substr($filesmatch, 0, -1)).')';
$php_options_text.= ' <FilesMatch \.'.$filesmatch.'$>'. "\n";
$php_options_text.= ' SetHandler proxy:unix:' . $php->getInterface()->getSocketFile() . '|fcgi://localhost'. "\n";
$php_options_text.= ' </FilesMatch>' . "\n";
$filesmatch = '(' . str_replace(".", "\.", substr($filesmatch, 0, - 1)) . ')';
$php_options_text .= ' <FilesMatch \.' . $filesmatch . '$>' . "\n";
$php_options_text .= ' SetHandler proxy:unix:' . $php->getInterface()->getSocketFile() . '|fcgi://localhost' . "\n";
$php_options_text .= ' </FilesMatch>' . "\n";
$mypath_dir = new \Froxlor\Http\Directory($domain['documentroot']);
// only create the require all granted if there is not active directory-protection
// for this path, as this would be the first require and therefore grant all access
if ($mypath_dir->isUserProtected() == false) {
$php_options_text.= ' <Directory "' . \Froxlor\FileDir::makeCorrectDir($domain['documentroot']) . '">' . "\n";
// only create the require all granted if there is not active directory-protection
// for this path, as this would be the first require and therefore grant all access
if ($mypath_dir->isUserProtected() == false) {
$php_options_text .= ' <Directory "' . \Froxlor\FileDir::makeCorrectDir($domain['documentroot']) . '">' . "\n";
if ($phpconfig['pass_authorizationheader'] == '1') {
$php_options_text.= ' CGIPassAuth On' . "\n";
$php_options_text .= ' CGIPassAuth On' . "\n";
}
$php_options_text.= ' Require all granted' . "\n";
$php_options_text.= ' AllowOverride All' . "\n";
$php_options_text.= ' </Directory>' . "\n";
} elseif ($phpconfig['pass_authorizationheader'] == '1') {
$php_options_text .= ' Require all granted' . "\n";
$php_options_text .= ' AllowOverride All' . "\n";
$php_options_text .= ' </Directory>' . "\n";
} elseif ($phpconfig['pass_authorizationheader'] == '1') {
// allow Pass of Authorization header
$php_options_text.= ' <Directory "' . \Froxlor\FileDir::makeCorrectDir($domain['documentroot']) . '">' . "\n";
$php_options_text.= ' CGIPassAuth On' . "\n";
$php_options_text.= ' </Directory>' . "\n";
}
$php_options_text .= ' <Directory "' . \Froxlor\FileDir::makeCorrectDir($domain['documentroot']) . '">' . "\n";
$php_options_text .= ' CGIPassAuth On' . "\n";
$php_options_text .= ' </Directory>' . "\n";
}
} else {
$addheader = "";
if ($phpconfig['pass_authorizationheader'] == '1') {
$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.= ' <Directory "' . \Froxlor\FileDir::makeCorrectDir($domain['documentroot']) . '">' . "\n";
$php_options_text .= ' FastCgiExternalServer ' . $php->getInterface()->getAliasConfigDir() . $srvName . ' -socket ' . $php->getInterface()->getSocketFile() . ' -idle-timeout ' . $phpconfig['fpm_settings']['idle_timeout'] . $addheader . "\n";
$php_options_text .= ' <Directory "' . \Froxlor\FileDir::makeCorrectDir($domain['documentroot']) . '">' . "\n";
$filesmatch = $phpconfig['fpm_settings']['limit_extensions'];
$extensions = explode(" ", $filesmatch);
$filesmatch = "";
foreach ($extensions as $ext) {
$filesmatch .= substr($ext, 1).'|';
$filesmatch .= substr($ext, 1) . '|';
}
// start block, cut off last pipe and close block
$filesmatch = '('.str_replace(".", "\.", substr($filesmatch, 0, -1)).')';
$php_options_text.= ' <FilesMatch \.'.$filesmatch.'$>'. "\n";
$php_options_text.= ' SetHandler php-fastcgi'. "\n";
$php_options_text.= ' Action php-fastcgi /fastcgiphp' . "\n";
$php_options_text.= ' Options +ExecCGI' . "\n";
$php_options_text.= ' </FilesMatch>' . "\n";
$filesmatch = '(' . str_replace(".", "\.", substr($filesmatch, 0, - 1)) . ')';
$php_options_text .= ' <FilesMatch \.' . $filesmatch . '$>' . "\n";
$php_options_text .= ' SetHandler php-fastcgi' . "\n";
$php_options_text .= ' Action php-fastcgi /fastcgiphp' . "\n";
$php_options_text .= ' Options +ExecCGI' . "\n";
$php_options_text .= ' </FilesMatch>' . "\n";
// >=apache-2.4 enabled?
if (Settings::Get('system.apache24') == '1') {
$mypath_dir = new \Froxlor\Http\Directory($domain['documentroot']);
// only create the require all granted if there is not active directory-protection
// for this path, as this would be the first require and therefore grant all access
if ($mypath_dir->isUserProtected() == false) {
$php_options_text.= ' Require all granted' . "\n";
$php_options_text.= ' AllowOverride All' . "\n";
}
$mypath_dir = new \Froxlor\Http\Directory($domain['documentroot']);
// only create the require all granted if there is not active directory-protection
// for this path, as this would be the first require and therefore grant all access
if ($mypath_dir->isUserProtected() == false) {
$php_options_text .= ' Require all granted' . "\n";
$php_options_text .= ' AllowOverride All' . "\n";
}
} else {
$php_options_text.= ' Order allow,deny' . "\n";
$php_options_text.= ' allow from all' . "\n";
$php_options_text .= ' Order allow,deny' . "\n";
$php_options_text .= ' allow from all' . "\n";
}
$php_options_text.= ' </Directory>' . "\n";
$php_options_text.= ' Alias /fastcgiphp ' . $php->getInterface()->getAliasConfigDir() . $srvName . "\n";
$php_options_text .= ' </Directory>' . "\n";
$php_options_text .= ' Alias /fastcgiphp ' . $php->getInterface()->getAliasConfigDir() . $srvName . "\n";
}
}
else
{
$php_options_text.= ' FcgidIdleTimeout ' . Settings::Get('system.mod_fcgid_idle_timeout') . "\n";
if((int)Settings::Get('system.mod_fcgid_wrapper') == 0)
{
$php_options_text.= ' SuexecUserGroup "' . $domain['loginname'] . '" "' . $domain['loginname'] . '"' . "\n";
$php_options_text.= ' ScriptAlias /php/ ' . $php->getInterface()->getConfigDir() . "\n";
}
else
{
$php_options_text.= ' SuexecUserGroup "' . $domain['loginname'] . '" "' . $domain['loginname'] . '"' . "\n";
$php_options_text.= ' <Directory "' . \Froxlor\FileDir::makeCorrectDir($domain['documentroot']) . '">' . "\n";
} else {
$php_options_text .= ' FcgidIdleTimeout ' . Settings::Get('system.mod_fcgid_idle_timeout') . "\n";
if ((int) Settings::Get('system.mod_fcgid_wrapper') == 0) {
$php_options_text .= ' SuexecUserGroup "' . $domain['loginname'] . '" "' . $domain['loginname'] . '"' . "\n";
$php_options_text .= ' ScriptAlias /php/ ' . $php->getInterface()->getConfigDir() . "\n";
} else {
$php_options_text .= ' SuexecUserGroup "' . $domain['loginname'] . '" "' . $domain['loginname'] . '"' . "\n";
$php_options_text .= ' <Directory "' . \Froxlor\FileDir::makeCorrectDir($domain['documentroot']) . '">' . "\n";
$file_extensions = explode(' ', $phpconfig['file_extensions']);
$php_options_text.= ' <FilesMatch "\.(' . implode('|', $file_extensions) . ')$">' . "\n";
$php_options_text.= ' SetHandler fcgid-script' . "\n";
foreach($file_extensions as $file_extension)
{
$php_options_text.= ' FcgidWrapper ' . $php->getInterface()->getStarterFile() . ' .' . $file_extension . "\n";
$php_options_text .= ' <FilesMatch "\.(' . implode('|', $file_extensions) . ')$">' . "\n";
$php_options_text .= ' SetHandler fcgid-script' . "\n";
foreach ($file_extensions as $file_extension) {
$php_options_text .= ' FcgidWrapper ' . $php->getInterface()->getStarterFile() . ' .' . $file_extension . "\n";
}
$php_options_text.= ' Options +ExecCGI' . "\n";
$php_options_text.= ' </FilesMatch>' . "\n";
$php_options_text .= ' Options +ExecCGI' . "\n";
$php_options_text .= ' </FilesMatch>' . "\n";
// >=apache-2.4 enabled?
if (Settings::Get('system.apache24') == '1') {
$mypath_dir = new \Froxlor\Http\Directory($domain['documentroot']);
// only create the require all granted if there is not active directory-protection
// for this path, as this would be the first require and therefore grant all access
if ($mypath_dir->isUserProtected() == false) {
$php_options_text.= ' Require all granted' . "\n";
$php_options_text.= ' AllowOverride All' . "\n";
}
$mypath_dir = new \Froxlor\Http\Directory($domain['documentroot']);
// only create the require all granted if there is not active directory-protection
// for this path, as this would be the first require and therefore grant all access
if ($mypath_dir->isUserProtected() == false) {
$php_options_text .= ' Require all granted' . "\n";
$php_options_text .= ' AllowOverride All' . "\n";
}
} else {
$php_options_text.= ' Order allow,deny' . "\n";
$php_options_text.= ' allow from all' . "\n";
$php_options_text .= ' Order allow,deny' . "\n";
$php_options_text .= ' allow from all' . "\n";
}
$php_options_text.= ' </Directory>' . "\n";
$php_options_text .= ' </Directory>' . "\n";
}
}
@@ -161,10 +150,8 @@ class ApacheFcgi extends Apache
// create php.ini (fpm does nothing here, as it
// defines ini-settings in its pool config)
$php->getInterface()->createIniFile($phpconfig);
}
else
{
$php_options_text.= ' # PHP is disabled for this vHost' . "\n";
} else {
$php_options_text .= ' # PHP is disabled for this vHost' . "\n";
}
return $php_options_text;
@@ -172,23 +159,16 @@ class ApacheFcgi extends Apache
public function createOwnVhostStarter()
{
if (Settings::Get('system.mod_fcgid_ownvhost') == '1'
|| (Settings::Get('phpfpm.enabled') == '1'
&& Settings::Get('phpfpm.enabled_ownvhost') == '1')
) {
if (Settings::Get('system.mod_fcgid_ownvhost') == '1' || (Settings::Get('phpfpm.enabled') == '1' && Settings::Get('phpfpm.enabled_ownvhost') == '1')) {
$mypath = \Froxlor\Froxlor::getInstallDir();
if (Settings::Get('system.mod_fcgid_ownvhost') == '1')
{
if (Settings::Get('system.mod_fcgid_ownvhost') == '1') {
$user = Settings::Get('system.mod_fcgid_httpuser');
$group = Settings::Get('system.mod_fcgid_httpgroup');
}
elseif(Settings::Get('phpfpm.enabled') == '1'
&& Settings::Get('phpfpm.enabled_ownvhost') == '1'
) {
} elseif (Settings::Get('phpfpm.enabled') == '1' && Settings::Get('phpfpm.enabled_ownvhost') == '1') {
$user = Settings::Get('phpfpm.vhost_httpuser');
$group = Settings::Get('phpfpm.vhost_httpgroup');
// get fpm config
$fpm_sel_stmt = Database::prepare("
SELECT f.id FROM `" . TABLE_PANEL_FPMDAEMONS . "` f
@@ -204,8 +184,8 @@ class ApacheFcgi extends Apache
'id' => 'none',
'domain' => Settings::Get('system.hostname'),
'adminid' => 1, /* first admin-user (superadmin) */
'mod_fcgid_starter' => -1,
'mod_fcgid_maxrequests' => -1,
'mod_fcgid_starter' => - 1,
'mod_fcgid_maxrequests' => - 1,
'guid' => $user,
'openbasedir' => 0,
'email' => Settings::Get('panel.adminmail'),

View File

@@ -1,4 +1,7 @@
<?php if (!defined('MASTER_CRONJOB')) die('You cannot access this file directly!');
<?php
if (! defined('MASTER_CRONJOB'))
die('You cannot access this file directly!');
/**
* This file is part of the Froxlor project.
@@ -8,17 +11,16 @@
* 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 Cron
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Cron
*
*/
use \Froxlor\Database;
use \Froxlor\Settings;
use Froxlor\Database;
use Froxlor\Settings;
if ((int)Settings::Get('system.report_webmax') > 0)
{
if ((int) Settings::Get('system.report_webmax') > 0) {
/**
* report about diskusage for customers
*/
@@ -34,11 +36,7 @@ if ((int)Settings::Get('system.report_webmax') > 0)
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
if (isset($row['diskspace'])
&& $row['diskspace_used'] != null
&& $row['diskspace_used'] > 0
&& (($row['diskspace_used'] * 100) / $row['diskspace']) >= (int)Settings::Get('system.report_webmax')
) {
if (isset($row['diskspace']) && $row['diskspace_used'] != null && $row['diskspace_used'] > 0 && (($row['diskspace_used'] * 100) / $row['diskspace']) >= (int) Settings::Get('system.report_webmax')) {
$rep_userinfo = array(
'name' => $row['name'],
@@ -58,12 +56,16 @@ if ((int)Settings::Get('system.report_webmax') > 0)
SELECT `file` FROM `" . TABLE_PANEL_LANGUAGE . "`
WHERE `language` = :deflang
");
$lngfile = Database::pexecute_first($lngfile_stmt, array('deflang' => $row['def_language']));
$lngfile = Database::pexecute_first($lngfile_stmt, array(
'deflang' => $row['def_language']
));
if ($lngfile !== null) {
$langfile = $lngfile['file'];
} else {
$lngfile = Database::pexecute_first($lngfile_stmt, array('deflang' => Settings::Get('panel.standardlanguage')));
$lngfile = Database::pexecute_first($lngfile_stmt, array(
'deflang' => Settings::Get('panel.standardlanguage')
));
$langfile = $lngfile['file'];
}
@@ -99,7 +101,7 @@ if ((int)Settings::Get('system.report_webmax') > 0)
$mail->MsgHTML(nl2br($mail_body));
$mail->AddAddress($row['email'], $row['name']);
$mail->Send();
} catch(\PHPMailer\PHPMailer\Exception $e) {
} catch (\PHPMailer\PHPMailer\Exception $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (Exception $e) {
@@ -117,7 +119,9 @@ if ((int)Settings::Get('system.report_webmax') > 0)
UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `reportsent` = '2'
WHERE `customerid` = :customerid
");
Database::pexecute($upd_stmt, array('customerid' => $row['customerid']));
Database::pexecute($upd_stmt, array(
'customerid' => $row['customerid']
));
}
}
@@ -130,11 +134,7 @@ if ((int)Settings::Get('system.report_webmax') > 0)
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
if (isset($row['diskspace'])
&& $row['diskspace_used'] != null
&& $row['diskspace_used'] > 0
&& (($row['diskspace_used'] * 100) / $row['diskspace']) >= (int)Settings::Get('system.report_webmax')
) {
if (isset($row['diskspace']) && $row['diskspace_used'] != null && $row['diskspace_used'] > 0 && (($row['diskspace_used'] * 100) / $row['diskspace']) >= (int) Settings::Get('system.report_webmax')) {
$replace_arr = array(
'NAME' => $row['name'],
@@ -148,12 +148,16 @@ if ((int)Settings::Get('system.report_webmax') > 0)
SELECT `file` FROM `" . TABLE_PANEL_LANGUAGE . "`
WHERE `language` = :deflang
");
$lngfile = Database::pexecute_first($lngfile_stmt, array('deflang' => $row['def_language']));
$lngfile = Database::pexecute_first($lngfile_stmt, array(
'deflang' => $row['def_language']
));
if ($lngfile !== null) {
$langfile = $lngfile['file'];
} else {
$lngfile = Database::pexecute_first($lngfile_stmt, array('deflang' => Settings::Get('panel.standardlanguage')));
$lngfile = Database::pexecute_first($lngfile_stmt, array(
'deflang' => Settings::Get('panel.standardlanguage')
));
$langfile = $lngfile['file'];
}
@@ -189,7 +193,7 @@ if ((int)Settings::Get('system.report_webmax') > 0)
$mail->MsgHTML(nl2br($mail_body));
$mail->AddAddress($row['email'], $row['name']);
$mail->Send();
} catch(\PHPMailer\PHPMailer\Exception $e) {
} catch (\PHPMailer\PHPMailer\Exception $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (Exception $e) {
@@ -207,7 +211,9 @@ if ((int)Settings::Get('system.report_webmax') > 0)
UPDATE `" . TABLE_PANEL_ADMINS . "` SET `reportsent` = '2'
WHERE `adminid` = :adminid
");
Database::pexecute($upd_stmt, array('adminid' => $row['adminid']));
Database::pexecute($upd_stmt, array(
'adminid' => $row['adminid']
));
}
}
} // webmax > 0