fix up some cron related things

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2018-12-22 20:01:10 +01:00
parent c1cd0004bf
commit 7f82038255
13 changed files with 200 additions and 190 deletions

View File

@@ -207,7 +207,7 @@ if ($page == 'overview') {
$count = 0;
$htaccess = '';
$cperlenabled = customerHasPerlEnabled($userinfo['customerid']);
$cperlenabled = \Froxlor\Customer\Customer::customerHasPerlEnabled($userinfo['customerid']);
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
if ($paging->checkDisplay($i)) {
@@ -270,7 +270,7 @@ if ($page == 'overview') {
));
} else {
$pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']);
$cperlenabled = customerHasPerlEnabled($userinfo['customerid']);
$cperlenabled = \Froxlor\Customer\Customer::customerHasPerlEnabled($userinfo['customerid']);
$htaccess_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htaccess_add.php';
$htaccess_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($htaccess_add_data);
@@ -309,7 +309,7 @@ if ($page == 'overview') {
$result['error404path'] = $result['error404path'];
$result['error403path'] = $result['error403path'];
$result['error500path'] = $result['error500path'];
$cperlenabled = customerHasPerlEnabled($userinfo['customerid']);
$cperlenabled = \Froxlor\Customer\Customer::customerHasPerlEnabled($userinfo['customerid']);
/*
* $options_indexes = \Froxlor\UI\HTML::makeyesno('options_indexes', '1', '0', $result['options_indexes']);
* $options_cgi = \Froxlor\UI\HTML::makeyesno('options_cgi', '1', '0', $result['options_cgi']);

View File

@@ -59,14 +59,14 @@ class Apache extends HttpConfigBase
// so we need to create a dummy
$_conffiles = glob(\Froxlor\FileDir::makeCorrectFile($restart_cmd['config_dir'] . "/*.conf"));
if ($_conffiles === false || empty($_conffiles)) {
\Froxlor\FroxlorLogger::getInstance()->logAction(CRON_ACTION, LOG_INFO, 'apache::reload: fpm config directory "' . $restart_cmd['config_dir'] . '" is empty. Creating dummy.');
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_INFO, 'apache::reload: fpm config directory "' . $restart_cmd['config_dir'] . '" is empty. Creating dummy.');
Fpm::createDummyPool($restart_cmd['config_dir']);
}
\Froxlor\FroxlorLogger::getInstance()->logAction(CRON_ACTION, LOG_INFO, 'apache::reload: running ' . $restart_cmd['reload_cmd']);
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_INFO, 'apache::reload: running ' . $restart_cmd['reload_cmd']);
\Froxlor\FileDir::safe_exec(escapeshellcmd($restart_cmd['reload_cmd']));
}
}
\Froxlor\FroxlorLogger::getInstance()->logAction(CRON_ACTION, LOG_INFO, 'apache::reload: reloading apache');
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_INFO, 'apache::reload: reloading apache');
\Froxlor\FileDir::safe_exec(escapeshellcmd(Settings::Get('system.apachereload_command')));
}
@@ -110,7 +110,7 @@ class Apache extends HttpConfigBase
$this->virtualhosts_data[$ocsp_cache_filename] = 'SSLStaplingCache ' . Settings::Get('system.apache24_ocsp_cache_path') . "\n";
} else {
if (file_exists($ocsp_cache_filename)) {
\Froxlor\FroxlorLogger::getInstance()->logAction(CRON_ACTION, LOG_NOTICE, 'apache::_createStandardDirectoryEntry: unlinking ' . basename($ocsp_cache_filename));
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_NOTICE, 'apache::_createStandardDirectoryEntry: unlinking ' . basename($ocsp_cache_filename));
unlink(\Froxlor\FileDir::makeCorrectFile($ocsp_cache_filename));
}
}
@@ -166,7 +166,7 @@ class Apache extends HttpConfigBase
$ipport = $row_ipsandports['ip'] . ':' . $row_ipsandports['port'];
}
\Froxlor\FroxlorLogger::getInstance()->logAction(CRON_ACTION, LOG_INFO, 'apache::createIpPort: creating ip/port settings for ' . $ipport);
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_INFO, 'apache::createIpPort: creating ip/port settings for ' . $ipport);
$vhosts_filename = \Froxlor\FileDir::makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/10_froxlor_ipandport_' . trim(str_replace(':', '.', $row_ipsandports['ip']), '.') . '.' . $row_ipsandports['port'] . '.conf');
if (! isset($this->virtualhosts_data[$vhosts_filename])) {
@@ -175,16 +175,16 @@ class Apache extends HttpConfigBase
if ($row_ipsandports['listen_statement'] == '1') {
$this->virtualhosts_data[$vhosts_filename] .= 'Listen ' . $ipport . "\n";
\Froxlor\FroxlorLogger::getInstance()->logAction(CRON_ACTION, LOG_DEBUG, $ipport . ' :: inserted listen-statement');
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_DEBUG, $ipport . ' :: inserted listen-statement');
}
if ($row_ipsandports['namevirtualhost_statement'] == '1') {
// >=apache-2.4 enabled?
if (Settings::Get('system.apache24') == '1') {
\Froxlor\FroxlorLogger::getInstance()->logAction(CRON_ACTION, LOG_NOTICE, $ipport . ' :: namevirtualhost-statement no longer needed for apache-2.4');
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_NOTICE, $ipport . ' :: namevirtualhost-statement no longer needed for apache-2.4');
} else {
$this->virtualhosts_data[$vhosts_filename] .= 'NameVirtualHost ' . $ipport . "\n";
\Froxlor\FroxlorLogger::getInstance()->logAction(CRON_ACTION, LOG_DEBUG, $ipport . ' :: inserted namevirtualhost-statement');
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_DEBUG, $ipport . ' :: inserted namevirtualhost-statement');
}
}
@@ -423,7 +423,7 @@ class Apache extends HttpConfigBase
if (! file_exists($row_ipsandports['ssl_cert_file'])) {
// explicitly disable ssl for this vhost
$row_ipsandports['ssl_cert_file'] = "";
\Froxlor\FroxlorLogger::getInstance()->logAction(CRON_ACTION, LOG_DEBUG, 'System certificate file "' . Settings::Get('system.ssl_cert_file') . '" does not seem to exist. Disabling SSL-vhost for "' . Settings::Get('system.hostname') . '"');
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_DEBUG, 'System certificate file "' . Settings::Get('system.ssl_cert_file') . '" does not seem to exist. Disabling SSL-vhost for "' . Settings::Get('system.hostname') . '"');
}
}
@@ -466,7 +466,7 @@ class Apache extends HttpConfigBase
// check for existence, #1485
if (! file_exists($domain['ssl_cert_file'])) {
\Froxlor\FroxlorLogger::getInstance()->logAction(CRON_ACTION, LOG_ERR, $ipport . ' :: certificate file "' . $domain['ssl_cert_file'] . '" does not exist! Cannot create ssl-directives');
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_ERR, $ipport . ' :: certificate file "' . $domain['ssl_cert_file'] . '" does not exist! Cannot create ssl-directives');
} else {
$this->virtualhosts_data[$vhosts_filename] .= ' SSLEngine On' . "\n";
@@ -493,7 +493,7 @@ class Apache extends HttpConfigBase
if ($domain['ssl_key_file'] != '') {
// check for existence, #1485
if (! file_exists($domain['ssl_key_file'])) {
\Froxlor\FroxlorLogger::getInstance()->logAction(CRON_ACTION, LOG_ERR, $ipport . ' :: certificate key file "' . $domain['ssl_key_file'] . '" does not exist! Cannot create ssl-directives');
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_ERR, $ipport . ' :: certificate key file "' . $domain['ssl_key_file'] . '" does not exist! Cannot create ssl-directives');
} else {
$this->virtualhosts_data[$vhosts_filename] .= ' SSLCertificateKeyFile ' . \Froxlor\FileDir::makeCorrectFile($domain['ssl_key_file']) . "\n";
}
@@ -502,7 +502,7 @@ class Apache extends HttpConfigBase
if ($domain['ssl_ca_file'] != '') {
// check for existence, #1485
if (! file_exists($domain['ssl_ca_file'])) {
\Froxlor\FroxlorLogger::getInstance()->logAction(CRON_ACTION, LOG_ERR, $ipport . ' :: certificate CA file "' . $domain['ssl_ca_file'] . '" does not exist! Cannot create ssl-directives');
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_ERR, $ipport . ' :: certificate CA file "' . $domain['ssl_ca_file'] . '" does not exist! Cannot create ssl-directives');
} else {
$this->virtualhosts_data[$vhosts_filename] .= ' SSLCACertificateFile ' . \Froxlor\FileDir::makeCorrectFile($domain['ssl_ca_file']) . "\n";
}
@@ -512,7 +512,7 @@ class Apache extends HttpConfigBase
if ($domain['ssl_cert_chainfile'] != '') {
// check for existence, #1485
if (! file_exists($domain['ssl_cert_chainfile'])) {
\Froxlor\FroxlorLogger::getInstance()->logAction(CRON_ACTION, LOG_ERR, $ipport . ' :: certificate chain file "' . $domain['ssl_cert_chainfile'] . '" does not exist! Cannot create ssl-directives');
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_ERR, $ipport . ' :: certificate chain file "' . $domain['ssl_cert_chainfile'] . '" does not exist! Cannot create ssl-directives');
} else {
$this->virtualhosts_data[$vhosts_filename] .= ' SSLCertificateChainFile ' . \Froxlor\FileDir::makeCorrectFile($domain['ssl_cert_chainfile']) . "\n";
}
@@ -521,7 +521,7 @@ class Apache extends HttpConfigBase
} else {
// if there is no cert-file specified but we are generating a ssl-vhost,
// we should return an empty string because this vhost would suck dick, ref #1583
\Froxlor\FroxlorLogger::getInstance()->logAction(CRON_ACTION, LOG_ERR, $domain['domain'] . ' :: empty certificate file! Cannot create ssl-directives');
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_ERR, $domain['domain'] . ' :: empty certificate file! Cannot create ssl-directives');
$this->virtualhosts_data[$vhosts_filename] = $without_vhost;
$this->virtualhosts_data[$vhosts_filename] .= '# no ssl-certificate was specified for this domain, therefore no explicit vhost-container is being generated';
$close_vhost = false;
@@ -531,7 +531,7 @@ class Apache extends HttpConfigBase
if ($close_vhost) {
$this->virtualhosts_data[$vhosts_filename] .= '</VirtualHost>' . "\n";
}
\Froxlor\FroxlorLogger::getInstance()->logAction(CRON_ACTION, LOG_DEBUG, $ipport . ' :: inserted vhostcontainer');
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_DEBUG, $ipport . ' :: inserted vhostcontainer');
}
unset($vhosts_filename);
}
@@ -566,14 +566,14 @@ class Apache extends HttpConfigBase
if ($domain['openbasedir'] == '1') {
if ($domain['openbasedir_path'] == '1' || strstr($domain['documentroot'], ":") !== false) {
$_phpappendopenbasedir = appendOpenBasedirPath($domain['customerroot'], true);
$_phpappendopenbasedir = \Froxlor\Domain\Domain::appendOpenBasedirPath($domain['customerroot'], true);
} else {
$_phpappendopenbasedir = appendOpenBasedirPath($domain['documentroot'], true);
$_phpappendopenbasedir = \Froxlor\Domain\Domain::appendOpenBasedirPath($domain['documentroot'], true);
}
$_custom_openbasedir = explode(':', Settings::Get('system.phpappendopenbasedir'));
foreach ($_custom_openbasedir as $cobd) {
$_phpappendopenbasedir .= appendOpenBasedirPath($cobd);
$_phpappendopenbasedir .= \Froxlor\Domain\Domain::appendOpenBasedirPath($cobd);
}
$php_options_text .= ' php_admin_value open_basedir "' . $_phpappendopenbasedir . '"' . "\n";
@@ -821,7 +821,7 @@ class Apache extends HttpConfigBase
// be sure to build the awstats conf file as well
// 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
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);
}
}
@@ -944,7 +944,7 @@ class Apache extends HttpConfigBase
if (! file_exists($domain['ssl_cert_file'])) {
// explicitly disable ssl for this vhost
$domain['ssl_cert_file'] = "";
\Froxlor\FroxlorLogger::getInstance()->logAction(CRON_ACTION, LOG_DEBUG, 'System certificate file "' . Settings::Get('system.ssl_cert_file') . '" does not seem to exist. Disabling SSL-vhost for "' . $domain['domain'] . '"');
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_DEBUG, 'System certificate file "' . Settings::Get('system.ssl_cert_file') . '" does not seem to exist. Disabling SSL-vhost for "' . $domain['domain'] . '"');
}
}
@@ -1013,7 +1013,7 @@ class Apache extends HttpConfigBase
} else {
// if there is no cert-file specified but we are generating a ssl-vhost,
// we should return an empty string because this vhost would suck dick, ref #1583
\Froxlor\FroxlorLogger::getInstance()->logAction(CRON_ACTION, LOG_ERR, $domain['domain'] . ' :: empty certificate file! Cannot create ssl-directives');
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_ERR, $domain['domain'] . ' :: empty certificate file! Cannot create ssl-directives');
return '# no ssl-certificate was specified for this domain, therefore no explicit vhost is being generated';
}
}
@@ -1047,7 +1047,7 @@ class Apache extends HttpConfigBase
$vhost_content .= ' </IfModule>' . "\n";
} else {
mkDirWithCorrectOwnership($domain['customerroot'], $domain['documentroot'], $domain['guid'], $domain['guid'], true, true);
\Froxlor\FileDir::mkDirWithCorrectOwnership($domain['customerroot'], $domain['documentroot'], $domain['guid'], $domain['guid'], true, true);
$vhost_content .= $this->getWebroot($domain);
if ($this->_deactivated == false) {
$vhost_content .= $this->composePhpOptions($domain, $ssl_vhost);
@@ -1081,7 +1081,7 @@ class Apache extends HttpConfigBase
$domains = WebserverBase::getVhostsToCreate();
foreach ($domains as $domain) {
\Froxlor\FroxlorLogger::getInstance()->logAction(CRON_ACTION, LOG_INFO, 'apache::createVirtualHosts: creating vhost container for domain ' . $domain['id'] . ', customer ' . $domain['loginname']);
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_INFO, 'apache::createVirtualHosts: creating vhost container for domain ' . $domain['id'] . ', customer ' . $domain['loginname']);
$vhosts_filename = $this->getVhostFilename($domain);
// Apply header
@@ -1146,7 +1146,7 @@ class Apache extends HttpConfigBase
foreach ($diroptions as $row_diroptions) {
$row_diroptions['path'] = \Froxlor\FileDir::makeCorrectDir($row_diroptions['path']);
mkDirWithCorrectOwnership($row_diroptions['customerroot'], $row_diroptions['path'], $row_diroptions['guid'], $row_diroptions['guid']);
\Froxlor\FileDir::mkDirWithCorrectOwnership($row_diroptions['customerroot'], $row_diroptions['path'], $row_diroptions['guid'], $row_diroptions['guid']);
$diroptions_filename = \Froxlor\FileDir::makeCorrectFile(Settings::Get('system.apacheconf_diroptions') . '/40_froxlor_diroption_' . md5($row_diroptions['path']) . '.conf');
if (! isset($this->diroptions_data[$diroptions_filename])) {
@@ -1154,7 +1154,7 @@ class Apache extends HttpConfigBase
}
if (is_dir($row_diroptions['path'])) {
$cperlenabled = customerHasPerlEnabled($row_diroptions['customerid']);
$cperlenabled = \Froxlor\Customer\Customer::customerHasPerlEnabled($row_diroptions['customerid']);
$this->diroptions_data[$diroptions_filename] .= '<Directory "' . $row_diroptions['path'] . '">' . "\n";
@@ -1167,7 +1167,7 @@ class Apache extends HttpConfigBase
} else {
$this->diroptions_data[$diroptions_filename] .= "\n";
}
\Froxlor\FroxlorLogger::getInstance()->logAction(CRON_ACTION, LOG_INFO, 'Setting Options +Indexes for ' . $row_diroptions['path']);
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_INFO, 'Setting Options +Indexes for ' . $row_diroptions['path']);
}
if (isset($row_diroptions['options_indexes']) && $row_diroptions['options_indexes'] == '0') {
@@ -1179,7 +1179,7 @@ class Apache extends HttpConfigBase
} else {
$this->diroptions_data[$diroptions_filename] .= "\n";
}
\Froxlor\FroxlorLogger::getInstance()->logAction(CRON_ACTION, LOG_INFO, 'Setting Options -Indexes for ' . $row_diroptions['path']);
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_INFO, 'Setting Options -Indexes for ' . $row_diroptions['path']);
}
$statusCodes = array(
@@ -1215,7 +1215,7 @@ class Apache extends HttpConfigBase
$this->diroptions_data[$diroptions_filename] .= ' Order allow,deny' . "\n";
$this->diroptions_data[$diroptions_filename] .= ' Allow from all' . "\n";
}
\Froxlor\FroxlorLogger::getInstance()->logAction(CRON_ACTION, LOG_INFO, 'Enabling perl execution for ' . $row_diroptions['path']);
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_INFO, 'Enabling perl execution for ' . $row_diroptions['path']);
// check for suexec-workaround, #319
if ((int) Settings::Get('perl.suexecworkaround') == 1) {
@@ -1283,7 +1283,7 @@ class Apache extends HttpConfigBase
public function writeConfigs()
{
// Write diroptions
\Froxlor\FroxlorLogger::getInstance()->logAction(CRON_ACTION, LOG_INFO, "apache::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_diroptions'));
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_INFO, "apache::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_diroptions'));
if (count($this->diroptions_data) > 0) {
$optsDir = new \Froxlor\Http\Directory(Settings::Get('system.apacheconf_diroptions'));
@@ -1304,7 +1304,7 @@ class Apache extends HttpConfigBase
fclose($diroptions_file_handler);
} else {
if (! file_exists(Settings::Get('system.apacheconf_diroptions'))) {
\Froxlor\FroxlorLogger::getInstance()->logAction(CRON_ACTION, LOG_NOTICE, 'apache::writeConfigs: mkdir ' . escapeshellarg(\Froxlor\FileDir::makeCorrectDir(Settings::Get('system.apacheconf_diroptions'))));
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_NOTICE, 'apache::writeConfigs: mkdir ' . escapeshellarg(\Froxlor\FileDir::makeCorrectDir(Settings::Get('system.apacheconf_diroptions'))));
\Froxlor\FileDir::safe_exec('mkdir ' . escapeshellarg(\Froxlor\FileDir::makeCorrectDir(Settings::Get('system.apacheconf_diroptions'))));
}
@@ -1322,7 +1322,7 @@ class Apache extends HttpConfigBase
}
// Write htpasswds
\Froxlor\FroxlorLogger::getInstance()->logAction(CRON_ACTION, LOG_INFO, "apache::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_htpasswddir'));
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_INFO, "apache::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_htpasswddir'));
if (count($this->htpasswds_data) > 0) {
if (! file_exists(Settings::Get('system.apacheconf_htpasswddir'))) {
@@ -1341,12 +1341,12 @@ class Apache extends HttpConfigBase
fclose($htpasswd_file_handler);
}
} else {
\Froxlor\FroxlorLogger::getInstance()->logAction(CRON_ACTION, LOG_WARNING, 'WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!');
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_WARNING, 'WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!');
}
}
// Write virtualhosts
\Froxlor\FroxlorLogger::getInstance()->logAction(CRON_ACTION, LOG_INFO, "apache::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_vhost'));
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_INFO, "apache::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_vhost'));
if (count($this->virtualhosts_data) > 0) {
$vhostDir = new \Froxlor\Http\Directory(Settings::Get('system.apacheconf_vhost'));
@@ -1379,7 +1379,7 @@ class Apache extends HttpConfigBase
fclose($vhosts_file_handler);
} else {
if (! file_exists(Settings::Get('system.apacheconf_vhost'))) {
\Froxlor\FroxlorLogger::getInstance()->logAction(CRON_ACTION, LOG_NOTICE, 'apache::writeConfigs: mkdir ' . escapeshellarg(\Froxlor\FileDir::makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_NOTICE, 'apache::writeConfigs: mkdir ' . escapeshellarg(\Froxlor\FileDir::makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
\Froxlor\FileDir::safe_exec('mkdir ' . escapeshellarg(\Froxlor\FileDir::makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
}

View File

@@ -39,7 +39,7 @@ 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'])) {
if (\Froxlor\Customer\Customer::customerHasPerlEnabled($domain['customerid'])) {
$php_options_text .= ' SuexecUserGroup "' . $domain['loginname'] . '" "' . $domain['loginname'] . '"' . "\n";
}

View File

@@ -61,9 +61,9 @@ class HttpConfigBase
{
if (! empty($ip_port) && $ip_port['docroot'] == '') {
if (Settings::Get('system.froxlordirectlyviahostname')) {
$mypath = \Froxlor\FileDir::makeCorrectDir(dirname(dirname(dirname(__FILE__))));
$mypath = \Froxlor\FileDir::makeCorrectDir(\Froxlor\Froxlor::getInstallDir());
} else {
$mypath = \Froxlor\FileDir::makeCorrectDir(dirname(dirname(dirname(dirname(__FILE__)))));
$mypath = \Froxlor\FileDir::makeCorrectDir(dirname(\Froxlor\Froxlor::getInstallDir()));
}
} else {
// user-defined docroot, #417

View File

@@ -337,7 +337,7 @@ class Lighttpd extends HttpConfigBase
$htaccess_text = '';
while ($row_htpasswds = $result_htpasswds_stmt->fetch(\PDO::FETCH_ASSOC)) {
$row_htpasswds['path'] = \Froxlor\FileDir::makeCorrectDir($row_htpasswds['path']);
mkDirWithCorrectOwnership($domain['documentroot'], $row_htpasswds['path'], $domain['guid'], $domain['guid']);
\Froxlor\FileDir::mkDirWithCorrectOwnership($domain['documentroot'], $row_htpasswds['path'], $domain['guid'], $domain['guid']);
$filename = $row_htpasswds['customerid'] . '-' . md5($row_htpasswds['path']) . '.htpasswd';
@@ -491,7 +491,7 @@ class Lighttpd extends HttpConfigBase
$vhost_content .= ' )' . "\n";
} else {
mkDirWithCorrectOwnership($domain['customerroot'], $domain['documentroot'], $domain['guid'], $domain['guid'], true, true);
\Froxlor\FileDir::mkDirWithCorrectOwnership($domain['customerroot'], $domain['documentroot'], $domain['guid'], $domain['guid'], true, true);
$only_webroot = false;
if ($ssl_vhost === false && $domain['ssl_redirect'] == '1') {
@@ -677,7 +677,7 @@ class Lighttpd extends HttpConfigBase
// be sure to build the awstats conf file as well
// 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
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);
}
}
@@ -715,7 +715,7 @@ class Lighttpd extends HttpConfigBase
}
$path = \Froxlor\FileDir::makeCorrectDir(substr($row['path'], strlen($domain['documentroot']) - 1));
mkDirWithCorrectOwnership($domain['documentroot'], $row['path'], $domain['guid'], $domain['guid']);
\Froxlor\FileDir::mkDirWithCorrectOwnership($domain['documentroot'], $row['path'], $domain['guid'], $domain['guid']);
// We need to remove the last slash, otherwise the regex wouldn't work
if ($row['path'] != $domain['documentroot']) {
@@ -728,9 +728,9 @@ class Lighttpd extends HttpConfigBase
$path_options = $error_string;
}
if (customerHasPerlEnabled($domain['customerid']) && $row['options_cgi'] != '0') {
if (\Froxlor\Customer\Customer::customerHasPerlEnabled($domain['customerid']) && $row['options_cgi'] != '0') {
$path = \Froxlor\FileDir::makeCorrectDir(substr($row['path'], strlen($domain['documentroot']) - 1));
mkDirWithCorrectOwnership($domain['documentroot'], $row['path'], $domain['guid'], $domain['guid']);
\Froxlor\FileDir::mkDirWithCorrectOwnership($domain['documentroot'], $row['path'], $domain['guid'], $domain['guid']);
// We need to remove the last slash, otherwise the regex wouldn't work
if ($row['path'] != $domain['documentroot']) {

View File

@@ -505,7 +505,7 @@ class Nginx extends HttpConfigBase
$vhost_content .= "\t\t" . 'return ' . $code . ' ' . $uri . '$request_uri;' . "\n";
$vhost_content .= "\t" . '}' . "\n";
} else {
mkDirWithCorrectOwnership($domain['customerroot'], $domain['documentroot'], $domain['guid'], $domain['guid'], true);
\Froxlor\FileDir::mkDirWithCorrectOwnership($domain['customerroot'], $domain['documentroot'], $domain['guid'], $domain['guid'], true);
$vhost_content .= $this->getLogFiles($domain);
$vhost_content .= $this->getWebroot($domain, $ssl_vhost);
@@ -728,7 +728,7 @@ class Nginx extends HttpConfigBase
// if ($row['options_indexes'] != '0') {
$path = \Froxlor\FileDir::makeCorrectDir(substr($row['path'], strlen($domain['documentroot']) - 1));
mkDirWithCorrectOwnership($domain['documentroot'], $row['path'], $domain['guid'], $domain['guid']);
\Froxlor\FileDir::mkDirWithCorrectOwnership($domain['documentroot'], $row['path'], $domain['guid'], $domain['guid']);
$path_options .= "\t" . '# ' . $path . "\n";
if ($path == '/') {
@@ -786,9 +786,9 @@ class Nginx extends HttpConfigBase
* Perl support
* required the fastCGI wrapper to be running to receive the CGI requests.
*/
if (customerHasPerlEnabled($domain['customerid']) && $row['options_cgi'] != '0') {
if (\Froxlor\Customer\Customer::customerHasPerlEnabled($domain['customerid']) && $row['options_cgi'] != '0') {
$path = \Froxlor\FileDir::makeCorrectDir(substr($row['path'], strlen($domain['documentroot']) - 1));
mkDirWithCorrectOwnership($domain['documentroot'], $row['path'], $domain['guid'], $domain['guid']);
\Froxlor\FileDir::mkDirWithCorrectOwnership($domain['documentroot'], $row['path'], $domain['guid'], $domain['guid']);
// We need to remove the last slash, otherwise the regex wouldn't work
if ($row['path'] != $domain['documentroot']) {
@@ -1082,7 +1082,7 @@ class Nginx extends HttpConfigBase
// be sure to build the awstats conf file as well
// 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
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

@@ -1,7 +1,7 @@
<?php
namespace Froxlor\Cron\Http\Php;
use Froxlor\Database;
use Froxlor\Database\Database;
use Froxlor\Settings;
/**
@@ -124,21 +124,21 @@ class Fcgid
$_custom_openbasedir = explode(':', Settings::Get('system.mod_fcgid_peardir'));
foreach ($_custom_openbasedir as $cobd) {
$_phpappendopenbasedir .= appendOpenBasedirPath($cobd);
$_phpappendopenbasedir .= \Froxlor\Domain\Domain::appendOpenBasedirPath($cobd);
}
$_custom_openbasedir = explode(':', Settings::Get('system.phpappendopenbasedir'));
foreach ($_custom_openbasedir as $cobd) {
$_phpappendopenbasedir .= appendOpenBasedirPath($cobd);
$_phpappendopenbasedir .= \Froxlor\Domain\Domain::appendOpenBasedirPath($cobd);
}
if ($this->_domain['openbasedir_path'] == '0' && strstr($this->_domain['documentroot'], ":") === false) {
$openbasedir = appendOpenBasedirPath($this->_domain['documentroot'], true);
$openbasedir = \Froxlor\Domain\Domain::appendOpenBasedirPath($this->_domain['documentroot'], true);
} else {
$openbasedir = appendOpenBasedirPath($this->_domain['customerroot'], true);
$openbasedir = \Froxlor\Domain\Domain::appendOpenBasedirPath($this->_domain['customerroot'], true);
}
$openbasedir .= appendOpenBasedirPath($this->getTempDir());
$openbasedir .= \Froxlor\Domain\Domain::appendOpenBasedirPath($this->getTempDir());
$openbasedir .= $_phpappendopenbasedir;
} else {
$openbasedir = 'none';

View File

@@ -1,7 +1,7 @@
<?php
namespace Froxlor\Cron\Http\Php;
use Froxlor\Database;
use Froxlor\Database\Database;
use Froxlor\Settings;
/**
@@ -199,21 +199,21 @@ class Fpm
$_phpappendopenbasedir = '';
$_custom_openbasedir = explode(':', Settings::Get('phpfpm.peardir'));
foreach ($_custom_openbasedir as $cobd) {
$_phpappendopenbasedir .= appendOpenBasedirPath($cobd);
$_phpappendopenbasedir .= \Froxlor\Domain\Domain::appendOpenBasedirPath($cobd);
}
$_custom_openbasedir = explode(':', Settings::Get('system.phpappendopenbasedir'));
foreach ($_custom_openbasedir as $cobd) {
$_phpappendopenbasedir .= appendOpenBasedirPath($cobd);
$_phpappendopenbasedir .= \Froxlor\Domain\Domain::appendOpenBasedirPath($cobd);
}
if ($this->_domain['openbasedir_path'] == '0' && strstr($this->_domain['documentroot'], ":") === false) {
$openbasedir = appendOpenBasedirPath($this->_domain['documentroot'], true);
$openbasedir = \Froxlor\Domain\Domain::appendOpenBasedirPath($this->_domain['documentroot'], true);
} else {
$openbasedir = appendOpenBasedirPath($this->_domain['customerroot'], true);
$openbasedir = \Froxlor\Domain\Domain::appendOpenBasedirPath($this->_domain['customerroot'], true);
}
$openbasedir .= appendOpenBasedirPath($this->getTempDir());
$openbasedir .= \Froxlor\Domain\Domain::appendOpenBasedirPath($this->getTempDir());
$openbasedir .= $_phpappendopenbasedir;
}
}

View File

@@ -1,7 +1,7 @@
<?php
namespace Froxlor\Cron\Http\Php;
use Froxlor\Database;
use Froxlor\Database\Database;
use Froxlor\Settings;
/**

View File

@@ -20,6 +20,13 @@ use Froxlor\Database\Database;
class MasterCron extends \Froxlor\Cron\FroxlorCron
{
private static $argv = null;
public static function setArguments($argv = null)
{
self::$argv = $argv;
}
public static function run()
{
define('MASTER_CRONJOB', 1);
@@ -28,6 +35,7 @@ class MasterCron extends \Froxlor\Cron\FroxlorCron
$jobs_to_run = array();
$argv = self::$argv;
/**
* check for --help
*/
@@ -61,7 +69,7 @@ class MasterCron extends \Froxlor\Cron\FroxlorCron
\Froxlor\System\Cronjob::inserttask('10');
// also regenerate cron.d-file
\Froxlor\System\Cronjob::inserttask('99');
addToQueue($jobs_to_run, 'tasks');
array_push($jobs_to_run, 'tasks');
} elseif (strtolower($argv[$x]) == '--debug') {
define('CRON_DEBUG_FLAG', 1);
} elseif (strtolower($argv[$x]) == '--no-fork') {
@@ -70,11 +78,13 @@ class MasterCron extends \Froxlor\Cron\FroxlorCron
elseif (substr(strtolower($argv[$x]), 0, 2) == '--') {
if (strlen($argv[$x]) > 3) {
$cronname = substr(strtolower($argv[$x]), 2);
addToQueue($jobs_to_run, $cronname);
array_push($jobs_to_run, $cronname);
}
}
}
}
$jobs_to_run = array_unique($jobs_to_run);
$cronlog->setCronDebugFlag(defined('CRON_DEBUG_FLAG'));

View File

@@ -202,7 +202,7 @@ class ReportsCron extends \Froxlor\Cron\FroxlorCron
AND `language` = :lang
AND `templategroup` = 'mails' AND `varname` = :varname
");
$resul2_data = array(
$result2_data = array(
'adminid' => $row['adminid'],
'lang' => $row['def_language'],
'varname' => 'trafficmaxpercent_subject'
@@ -210,7 +210,7 @@ class ReportsCron extends \Froxlor\Cron\FroxlorCron
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_subject = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['subject']), $replace_arr));
$resul2_data['varname'] = 'trafficmaxpercent_mailbody';
$result2_data['varname'] = 'trafficmaxpercent_mailbody';
$result2 = Database::pexecute_first($result2_stmt, $result2_data);
$mail_body = html_entity_decode(\Froxlor\PhpHelper::replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficmaxpercent']['mailbody']), $replace_arr));
@@ -352,6 +352,8 @@ class ReportsCron extends \Froxlor\Cron\FroxlorCron
WHERE `c`.`diskspace` > '0' AND `c`.`reportsent` <> '2'
");
$mail = new \Froxlor\System\Mailer(true);
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')) {
@@ -429,7 +431,7 @@ class ReportsCron extends \Froxlor\Cron\FroxlorCron
}
if ($_mailerror) {
$cronlog->logAction(CRON_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg);
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg);
echo "Error sending mail: " . $mailerr_msg . "\n";
}
@@ -522,7 +524,7 @@ class ReportsCron extends \Froxlor\Cron\FroxlorCron
}
if ($_mailerror) {
$cronlog->logAction(CRON_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg);
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg);
echo "Error sending mail: " . $mailerr_msg . "\n";
}

View File

@@ -28,7 +28,7 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
// Check Traffic-Lock
if (function_exists('pcntl_fork') && ! defined('CRON_NOFORK_FLAG')) {
$TrafficLock = \Froxlor\FileDir::makeCorrectFile(dirname($lockfile) . "/froxlor_cron_traffic.lock");
$TrafficLock = \Froxlor\FileDir::makeCorrectFile("/var/run/froxlor_cron_traffic.lock");
if (file_exists($TrafficLock) && is_numeric($TrafficPid = file_get_contents($TrafficLock))) {
if (function_exists('posix_kill')) {
$TrafficPidStatus = @posix_kill($TrafficPid, 0);
@@ -37,7 +37,7 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
$TrafficPidStatus = $TrafficPidStatus ? false : true;
}
if ($TrafficPidStatus) {
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'Traffic Run already in progress');
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_INFO, 'Traffic Run already in progress');
return 1;
}
}
@@ -53,7 +53,6 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
} // Child
elseif ($TrafficPid == 0) {
posix_setsid();
fclose($debugHandler);
// re-create db
Database::needRoot(false);
} // Fork failed
@@ -66,13 +65,13 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
} else {
$msg = "PHP compiled without pcntl.";
}
$cronlog->logAction(CRON_ACTION, LOG_INFO, $msg . " Not forking traffic-cron, this may take a long time!");
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_INFO, $msg . " Not forking traffic-cron, this may take a long time!");
}
/**
* TRAFFIC AND DISKUSAGE MESSURE
*/
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'Traffic run started...');
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_INFO, 'Traffic run started...');
$admin_traffic = array();
$domainlist = array();
$speciallogfile_domainlist = array();
@@ -124,11 +123,11 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
if (in_array(strtolower($row_database['databasename']), $databases_list)) {
// sum up data_length and index_length
$mysql_usage_result_stmt = Database::prepare("
SELECT SUM(data_length + index_length) AS customerusage
FROM information_schema.TABLES
WHERE table_schema = :database
GROUP BY table_schema;
");
SELECT SUM(data_length + index_length) AS customerusage
FROM information_schema.TABLES
WHERE table_schema = :database
GROUP BY table_schema;
");
// get the result
$mysql_usage_row = Database::pexecute_first($mysql_usage_result_stmt, array(
'database' => $row_database['databasename']
@@ -140,7 +139,7 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
// sum up result
$mysqlusage_all[$row_database['customerid']] += floatval($mysql_usage_row['customerusage']);
} else {
$cronlog->logAction(CRON_ACTION, LOG_WARNING, "Seems like the database " . $row_database['databasename'] . " had been removed manually.");
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_WARNING, "Seems like the database " . $row_database['databasename'] . " had been removed manually.");
}
}
@@ -164,7 +163,7 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
/**
* HTTP-Traffic
*/
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'http traffic for ' . $row['loginname'] . ' started...');
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_INFO, 'http traffic for ' . $row['loginname'] . ' started...');
$httptraffic = 0;
if (isset($domainlist[$row['customerid']]) && is_array($domainlist[$row['customerid']]) && count($domainlist[$row['customerid']]) != 0) {
@@ -193,7 +192,7 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
reset($speciallogfile_domainlist[$row['customerid']]);
if (Settings::Get('system.awstats_enabled') == '0') {
foreach ($speciallogfile_domainlist[$row['customerid']] as $domainid => $domain) {
$httptraffic += floatval(callWebalizerGetTraffic($row['loginname'] . '-' . $domain, $row['documentroot'] . '/webalizer/' . $domain . '/', $domain, $domainlist[$row['customerid']]));
$httptraffic += floatval(self::callWebalizerGetTraffic($row['loginname'] . '-' . $domain, $row['documentroot'] . '/webalizer/' . $domain . '/', $domain, $domainlist[$row['customerid']]));
}
}
}
@@ -205,23 +204,23 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
// will iterate through all customer-domains and the awstats-configs
// know the logfile-name, #246
if (Settings::Get('system.awstats_enabled') == '1') {
$httptraffic += floatval(callAwstatsGetTraffic($row['customerid'], $row['documentroot'] . '/awstats/', $domainlist[$row['customerid']]));
$httptraffic += floatval(self::callAwstatsGetTraffic($row['customerid'], $row['documentroot'] . '/awstats/', $domainlist[$row['customerid']]));
} else {
$httptraffic += floatval(callWebalizerGetTraffic($row['loginname'], $row['documentroot'] . '/webalizer/', $caption, $domainlist[$row['customerid']]));
$httptraffic += floatval(self::callWebalizerGetTraffic($row['loginname'], $row['documentroot'] . '/webalizer/', $caption, $domainlist[$row['customerid']]));
}
// make the stuff readable for the customer, #258
makeChownWithNewStats($row);
\Froxlor\Http\Statistics::makeChownWithNewStats($row);
}
/**
* FTP-Traffic
*/
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'ftp traffic for ' . $row['loginname'] . ' started...');
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_INFO, 'ftp traffic for ' . $row['loginname'] . ' started...');
$ftptraffic_stmt = Database::prepare("
SELECT SUM(`up_bytes`) AS `up_bytes_sum`, SUM(`down_bytes`) AS `down_bytes_sum`
FROM `" . TABLE_FTP_USERS . "` WHERE `customerid` = :customerid
");
SELECT SUM(`up_bytes`) AS `up_bytes_sum`, SUM(`down_bytes`) AS `down_bytes_sum`
FROM `" . TABLE_FTP_USERS . "` WHERE `customerid` = :customerid
");
$ftptraffic = Database::pexecute_first($ftptraffic_stmt, array(
'customerid' => $row['customerid']
));
@@ -234,8 +233,8 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
}
$upd_stmt = Database::prepare("
UPDATE `" . TABLE_FTP_USERS . "` SET `up_bytes` = '0', `down_bytes` = '0' WHERE `customerid` = :customerid
");
UPDATE `" . TABLE_FTP_USERS . "` SET `up_bytes` = '0', `down_bytes` = '0' WHERE `customerid` = :customerid
");
Database::pexecute($upd_stmt, array(
'customerid' => $row['customerid']
));
@@ -245,7 +244,7 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
*/
$mailtraffic = 0;
if (Settings::Get("system.mailtraffic_enabled")) {
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'mail traffic usage for ' . $row['loginname'] . " started...");
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_INFO, 'mail traffic usage for ' . $row['loginname'] . " started...");
$currentDate = date("Y-m-d");
@@ -268,10 +267,11 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
} else {
// Check if an entry for the given day exists
$stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_TRAFFIC . "`
WHERE `customerid` = :cid
AND `year` = :year
AND `month` = :month
AND `day` = :day");
WHERE `customerid` = :cid
AND `year` = :year
AND `month` = :month
AND `day` = :day
");
$params = array(
"cid" => $row['customerid'],
"year" => $year,
@@ -282,8 +282,9 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
if ($stmt->rowCount() > 0) {
$updRow = $stmt->fetch(\PDO::FETCH_ASSOC);
$upd_stmt = Database::prepare("UPDATE `" . TABLE_PANEL_TRAFFIC . "` SET
`mail` = :mail
WHERE `id` = :id");
`mail` = :mail
WHERE `id` = :id
");
Database::pexecute($upd_stmt, array(
"mail" => $updRow['mail'] + $dayTraffic,
"id" => $updRow['id']
@@ -297,7 +298,7 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
/**
* Total Traffic
*/
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'total traffic for ' . $row['loginname'] . ' started');
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_INFO, 'total traffic for ' . $row['loginname'] . ' started');
$current_traffic = array();
$current_traffic['http'] = floatval($httptraffic);
$current_traffic['ftp_up'] = floatval(($ftptraffic['up_bytes_sum'] / 1024));
@@ -317,23 +318,23 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
'mail' => $current_traffic['mail']
);
$ins_stmt = Database::prepare("
INSERT INTO `" . TABLE_PANEL_TRAFFIC . "` SET
`customerid` = :customerid,
`year` = :year,
`month` = :month,
`day` = :day,
`stamp` = :stamp,
`http` = :http,
`ftp_up` = :ftp_up,
`ftp_down` = :ftp_down,
`mail` = :mail
");
INSERT INTO `" . TABLE_PANEL_TRAFFIC . "` SET
`customerid` = :customerid,
`year` = :year,
`month` = :month,
`day` = :day,
`stamp` = :stamp,
`http` = :http,
`ftp_up` = :ftp_up,
`ftp_down` = :ftp_down,
`mail` = :mail
");
Database::pexecute($ins_stmt, $ins_data);
$sum_month_traffic_stmt = Database::prepare("
SELECT SUM(`http`) AS `http`, SUM(`ftp_up`) AS `ftp_up`, SUM(`ftp_down`) AS `ftp_down`, SUM(`mail`) AS `mail`
FROM `" . TABLE_PANEL_TRAFFIC . "` WHERE `year` = :year AND `month` = :month AND `customerid` = :customerid
");
SELECT SUM(`http`) AS `http`, SUM(`ftp_up`) AS `ftp_up`, SUM(`ftp_down`) AS `ftp_down`, SUM(`mail`) AS `mail`
FROM `" . TABLE_PANEL_TRAFFIC . "` WHERE `year` = :year AND `month` = :month AND `customerid` = :customerid
");
$sum_month_traffic = Database::pexecute_first($sum_month_traffic_stmt, array(
'year' => date('Y', time()),
'month' => date('m', time()),
@@ -360,7 +361,7 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
/**
* WebSpace-Usage
*/
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'calculating webspace usage for ' . $row['loginname']);
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_INFO, 'calculating webspace usage for ' . $row['loginname']);
$webspaceusage = 0;
// Using repquota, it's faster using this tool than using du traversing the complete directory
@@ -379,14 +380,14 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
$webspaceusage = floatval($webspaceusage['0']);
unset($back);
} else {
$cronlog->logAction(CRON_ACTION, LOG_WARNING, 'documentroot ' . $row['documentroot'] . ' does not exist');
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_WARNING, 'documentroot ' . $row['documentroot'] . ' does not exist');
}
}
/**
* MailSpace-Usage
*/
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'calculating mailspace usage for ' . $row['loginname']);
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_INFO, 'calculating mailspace usage for ' . $row['loginname']);
$emailusage = 0;
$maildir = \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.vmail_homedir') . $row['loginname']);
@@ -399,13 +400,13 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
$emailusage = floatval($emailusage['0']);
unset($back);
} else {
$cronlog->logAction(CRON_ACTION, LOG_WARNING, 'maildir ' . $maildir . ' does not exist');
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_WARNING, 'maildir ' . $maildir . ' does not exist');
}
/**
* MySQLSpace-Usage
*/
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'calculating mysqlspace usage for ' . $row['loginname']);
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_INFO, 'calculating mysqlspace usage for ' . $row['loginname']);
$mysqlusage = 0;
if (isset($mysqlusage_all[$row['customerid']])) {
@@ -429,16 +430,16 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
'mysql' => $current_diskspace['mysql']
);
$ins_stmt = Database::prepare("
INSERT INTO `" . TABLE_PANEL_DISKSPACE . "` SET
`customerid` = :customerid,
`year` = :year,
`month` = :month,
`day` = :day,
`stamp` = :stamp,
`webspace` = :webspace,
`mail` = :mail,
`mysql` = :mysql
");
INSERT INTO `" . TABLE_PANEL_DISKSPACE . "` SET
`customerid` = :customerid,
`year` = :year,
`month` = :month,
`day` = :day,
`stamp` = :stamp,
`webspace` = :webspace,
`mail` = :mail,
`mysql` = :mysql
");
Database::pexecute($ins_stmt, $ins_data);
if (! isset($admin_diskspace[$row['adminid']]) || ! is_array($admin_diskspace[$row['adminid']])) {
@@ -465,11 +466,11 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
'customerid' => $row['customerid']
);
$upd_stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET
`diskspace_used` = :diskspace,
`traffic_used` = :traffic
WHERE `customerid` = :customerid
");
UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET
`diskspace_used` = :diskspace,
`traffic_used` = :traffic
WHERE `customerid` = :customerid
");
Database::pexecute($upd_stmt, $upd_data);
/**
@@ -481,9 +482,9 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
'loginnamelike' => $row['loginname'] . Settings::Get('customer.ftpprefix') . "%"
);
$upd_stmt = Database::prepare("
UPDATE `" . TABLE_FTP_QUOTATALLIES . "` SET
`bytes_in_used` = :biu WHERE `name` = :loginname OR `name` LIKE :loginnamelike
");
UPDATE `" . TABLE_FTP_QUOTATALLIES . "` SET
`bytes_in_used` = :biu WHERE `name` = :loginname OR `name` LIKE :loginnamelike
");
Database::pexecute($upd_stmt, $upd_data);
/**
@@ -492,8 +493,8 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
if (Settings::Get('system.ftpserver') == "pureftpd") {
$result_quota_stmt = Database::prepare("
SELECT homedir FROM `" . TABLE_FTP_USERS . "` WHERE customerid = :customerid
");
SELECT homedir FROM `" . TABLE_FTP_USERS . "` WHERE customerid = :customerid
");
Database::pexecute($result_quota_stmt, array(
'customerid' => $row['customerid']
));
@@ -539,17 +540,17 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
'mail' => $admin_traffic[$row['adminid']]['mail']
);
$ins_stmt = Database::prepare("
INSERT INTO `" . TABLE_PANEL_TRAFFIC_ADMINS . "` SET
`adminid` = :adminid,
`year` = :year,
`month` = :month,
`day` = :day,
`stamp` = :stamp,
`http` = :http,
`ftp_up` = :ftp_up,
`ftp_down` = :ftp_down,
`mail` = :mail
");
INSERT INTO `" . TABLE_PANEL_TRAFFIC_ADMINS . "` SET
`adminid` = :adminid,
`year` = :year,
`month` = :month,
`day` = :day,
`stamp` = :stamp,
`http` = :http,
`ftp_up` = :ftp_up,
`ftp_down` = :ftp_down,
`mail` = :mail
");
Database::pexecute($ins_stmt, $ins_data);
$upd_data = array(
@@ -557,10 +558,10 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
'adminid' => $row['adminid']
);
$upd_stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_ADMINS . "` SET
`traffic_used` = :traffic
WHERE `adminid` = :adminid
");
UPDATE `" . TABLE_PANEL_ADMINS . "` SET
`traffic_used` = :traffic
WHERE `adminid` = :adminid
");
Database::pexecute($upd_stmt, $upd_data);
}
@@ -577,26 +578,26 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
'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
");
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(
'diskspace' => $admin_diskspace[$row['adminid']]['all'],
'adminid' => $row['adminid']
);
$upd_stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_ADMINS . "` SET
`diskspace_used` = :diskspace
WHERE `adminid` = :adminid
");
UPDATE `" . TABLE_PANEL_ADMINS . "` SET
`diskspace_used` = :diskspace
WHERE `adminid` = :adminid
");
Database::pexecute($upd_stmt, $upd_data);
}
}
@@ -609,7 +610,7 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
}
}
public static function awstatsDoSingleDomain($domain, $outputdir)
private static function awstatsDoSingleDomain($domain, $outputdir)
{
$returnval = 0;
@@ -630,15 +631,15 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
if (! file_exists($awbsp)) {
echo "WANRING: Necessary awstats_buildstaticpages.pl script could not be found, no traffic is being calculated and no stats are generated. Please check your AWStats-Path setting";
$cronlog->logAction(CRON_ACTION, LOG_WARNING, "Necessary awstats_buildstaticpages.pl script could not be found, no traffic is being calculated and no stats are generated. Please check your AWStats-Path setting");
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_WARNING, "Necessary awstats_buildstaticpages.pl script could not be found, no traffic is being calculated and no stats are generated. Please check your AWStats-Path setting");
exit();
}
$cronlog->logAction(CRON_ACTION, LOG_INFO, "Running awstats_buildstaticpages.pl for domain '" . $domain . "' (Output: '" . $staticOutputdir . "')");
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_INFO, "Running awstats_buildstaticpages.pl for domain '" . $domain . "' (Output: '" . $staticOutputdir . "')");
\Froxlor\FileDir::safe_exec($awbsp . ' -awstatsprog=' . escapeshellarg($awprog) . ' -update -month=' . date('m') . ' -year=' . date('Y') . ' -config=' . $domain . ' -dir=' . escapeshellarg($staticOutputdir));
// update our awstats index files
awstatsGenerateIndex($domain, $outputdir);
self::awstatsGenerateIndex($domain, $outputdir);
// the default selection is 'current',
// so link the latest dir to it
@@ -647,7 +648,7 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
// statistics file looks like: 'awstats[month][year].[domain].txt'
$file = \Froxlor\FileDir::makeCorrectFile($outputdir . '/awstats' . date('mY', time()) . '.' . $domain . '.txt');
$cronlog->logAction(CRON_ACTION, LOG_INFO, "Gathering traffic information from '" . $file . "'");
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_INFO, "Gathering traffic information from '" . $file . "'");
if (file_exists($file)) {
@@ -683,7 +684,7 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
return $returnval;
}
public static function awstatsGenerateIndex($domain, $outputdir)
private static function awstatsGenerateIndex($domain, $outputdir)
{
// Generation header
@@ -756,17 +757,15 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
return;
}
public static function callAwstatsGetTraffic($customerid, $outputdir, $usersdomainlist)
private static function callAwstatsGetTraffic($customerid, $outputdir, $usersdomainlist)
{
global $cronlog;
$returnval = 0;
foreach ($usersdomainlist as $domainid => $singledomain) {
foreach ($usersdomainlist as $singledomain) {
// as we check for the config-model awstats will only parse
// 'real' domains and no subdomains which are aliases in the
// model-config-file.
$returnval += awstatsDoSingleDomain($singledomain, $outputdir);
$returnval += self::awstatsDoSingleDomain($singledomain, $outputdir);
}
/**
@@ -784,10 +783,10 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
if ($customerid !== false) {
$result_stmt = Database::prepare("
SELECT SUM(`http`) as `trafficmonth` FROM `" . TABLE_PANEL_TRAFFIC . "`
WHERE `customerid` = :customerid
AND `year` = :year AND `month` = :month
");
SELECT SUM(`http`) as `trafficmonth` FROM `" . TABLE_PANEL_TRAFFIC . "`
WHERE `customerid` = :customerid
AND `year` = :year AND `month` = :month
");
$result_data = array(
'customerid' => $customerid,
'year' => date('Y', time()),
@@ -815,16 +814,14 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
* @return int Used traffic
* @author Florian Lippert <flo@syscp.org>
*/
public static function callWebalizerGetTraffic($logfile, $outputdir, $caption, $usersdomainlist)
private static function callWebalizerGetTraffic($logfile, $outputdir, $caption, $usersdomainlist)
{
global $cronlog;
$returnval = 0;
$logfile = \Froxlor\FileDir::makeCorrectFile(Settings::Get('system.logfiles_directory') . $logfile . '-access.log');
if (file_exists($logfile)) {
$domainargs = '';
foreach ($usersdomainlist as $domainid => $domain) {
foreach ($usersdomainlist as $domain) {
// hide referer
$domainargs .= ' -r ' . escapeshellarg($domain);
}
@@ -856,7 +853,7 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
$we = '/usr/local/bin/webalizer';
}
$cronlog->logAction(CRON_ACTION, LOG_INFO, "Running webalizer for domain '" . $caption . "'");
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_INFO, "Running webalizer for domain '" . $caption . "'");
\Froxlor\FileDir::safe_exec($we . ' ' . $verbosity . ' -p -o ' . escapeshellarg($outputdir) . ' -n ' . escapeshellarg($caption) . $domainargs . ' ' . escapeshellarg($logfile));
/**
@@ -867,7 +864,7 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
*/
$httptraffic = array();
$webalizer_hist = @file_get_contents($outputdir . 'webalizer.hist');
$cronlog->logAction(CRON_ACTION, LOG_INFO, "Gathering traffic information from '" . $webalizer_hist . "'");
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_INFO, "Gathering traffic information from '" . $webalizer_hist . "'");
$webalizer_hist_rows = explode("\n", $webalizer_hist);
foreach ($webalizer_hist_rows as $webalizer_hist_row) {
@@ -892,7 +889,7 @@ class TrafficCron extends \Froxlor\Cron\FroxlorCron
reset($httptraffic);
$httptrafficlast = array();
$webalizer_lasthist = @file_get_contents($outputdir . 'webalizer.hist.1');
$cronlog->logAction(CRON_ACTION, LOG_INFO, "Gathering traffic information from '" . $webalizer_lasthist . "'");
\Froxlor\FroxlorLogger::getInstanceOf()->logAction(CRON_ACTION, LOG_INFO, "Gathering traffic information from '" . $webalizer_lasthist . "'");
$webalizer_lasthist_rows = explode("\n", $webalizer_lasthist);
foreach ($webalizer_lasthist_rows as $webalizer_lasthist_row) {

View File

@@ -16,4 +16,5 @@
*/
require dirname(__DIR__) . '/vendor/autoload.php';
\Froxlor\Cron\MasterCron::setArguments($argv);
\Froxlor\Cron\MasterCron::run();