use namespaces in modules

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann 2018-12-18 13:45:05 +01:00
parent 9d314aaa3f
commit 6329042d40
No known key found for this signature in database
GPG Key ID: 55284EC83A4823B8
43 changed files with 203 additions and 96 deletions

View File

@ -3,6 +3,10 @@ if (! defined('AREA')) {
header("Location: index.php");
exit();
}
use Froxlor\Database as Database;
use Froxlor\Settings as Settings;
if (Settings::Get('2fa.enabled') != '1') {
dynamic_error("2FA not activated");
}

View File

@ -20,6 +20,10 @@
define('AREA', 'admin');
require './lib/init.php';
use Froxlor\Database as Database;
use Froxlor\Settings as Settings;
use Froxlor\Api\Commands\Admins as Admins;
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif(isset($_GET['id'])) {

View File

@ -20,6 +20,8 @@
define('AREA', 'admin');
require './lib/init.php';
use \Froxlor\Http\HttpClient;
// define update-uri
define('UPDATE_URI', "https://version.froxlor.org/Froxlor/api/" . $version);
define('RELEASE_URI', "https://autoupdate.froxlor.org/froxlor-{version}.zip");

View File

@ -18,6 +18,8 @@
define('AREA', 'admin');
require './lib/init.php';
use Froxlor\Settings as Settings;
if ($userinfo['change_serversettings'] == '1') {
if ($action == 'setconfigured')

View File

@ -18,6 +18,9 @@
define('AREA', 'admin');
require './lib/init.php';
use Froxlor\Database as Database;
use Froxlor\Api\Commands\Cronjobs as Cronjobs;
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif(isset($_GET['id'])) {

View File

@ -20,6 +20,10 @@
define('AREA', 'admin');
require './lib/init.php';
use Froxlor\Database as Database;
use Froxlor\Settings as Settings;
use Froxlor\Api\Commands\Customers as Customers;
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif(isset($_GET['id'])) {

View File

@ -19,6 +19,10 @@
define('AREA', 'admin');
require './lib/init.php';
use Froxlor\Database as Database;
use Froxlor\Settings as Settings;
use Froxlor\Api\Commands\Domains as Domains;
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {

View File

@ -20,6 +20,11 @@
define('AREA', 'admin');
require './lib/init.php';
use Froxlor\Database as Database;
use Froxlor\Settings as Settings;
use Froxlor\Api\Commands\Froxlor as Froxlor;
use Froxlor\Api\Commands\Admins as Admins;
if ($action == 'logout') {
$log->logAction(ADM_ACTION, LOG_NOTICE, "logged out");
@ -348,7 +353,7 @@ if ($page == 'overview') {
$mail->MsgHTML($mail_html);
$mail->AddAddress('error-reports@froxlor.org', 'Froxlor Developer Team');
$mail->Send();
} catch(phpmailerException $e) {
} catch(\PHPMailer\PHPMailer\Exception $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (Exception $e) {

View File

@ -19,6 +19,10 @@
define('AREA', 'admin');
require './lib/init.php';
use Froxlor\Database as Database;
use Froxlor\Settings as Settings;
use Froxlor\Api\Commands\IpsAndPorts as IpsAndPorts;
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {

View File

@ -20,6 +20,8 @@
define('AREA', 'admin');
require './lib/init.php';
use Froxlor\Database as Database;
if ($page == 'log'
&& $userinfo['change_serversettings'] == '1'
) {

View File

@ -20,6 +20,8 @@
define('AREA', 'admin');
require './lib/init.php';
use Froxlor\Database as Database;
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {

View File

@ -19,6 +19,10 @@
define('AREA', 'admin');
require './lib/init.php';
use Froxlor\Database as Database;
use Froxlor\Api\Commands\PhpSettings as PhpSettings;
use Froxlor\Api\Commands\FpmDaemons as FpmDaemons;
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {

View File

@ -17,6 +17,9 @@
define('AREA', 'admin');
require './lib/init.php';
use Froxlor\Database as Database;
use Froxlor\Settings as Settings;
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {

View File

@ -20,6 +20,9 @@
define('AREA', 'admin');
require './lib/init.php';
use Froxlor\Database as Database;
use Froxlor\Settings as Settings;
if (isset($_POST['subjectid'])) {
$subjectid = intval($_POST['subjectid']);
$mailbodyid = intval($_POST['mailbodyid']);

View File

@ -20,6 +20,9 @@
define('AREA', 'admin');
require './lib/init.php';
use Froxlor\Database as Database;
use Froxlor\Settings as Settings;
if (isset($_POST['id'])) {
$id = intval($_POST['id']);

View File

@ -19,6 +19,9 @@
define('AREA', 'admin');
require './lib/init.php';
use Froxlor\Database as Database;
use Froxlor\Settings as Settings;
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif(isset($_GET['id'])) {

View File

@ -18,6 +18,9 @@
define('AREA', 'admin');
require './lib/init.php';
use Froxlor\Database as Database;
use Froxlor\Settings as Settings;
if ($page == 'overview') {
$log->logAction(ADM_ACTION, LOG_NOTICE, "viewed admin_updates");

View File

@ -20,6 +20,8 @@ if (! defined('AREA')) {
*
*/
use Froxlor\Database as Database;
// This file is being included in admin_index and customer_index
// and therefore does not need to require lib/init.php

View File

@ -20,6 +20,11 @@
define('AREA', 'customer');
require './lib/init.php';
use Froxlor\Database as Database;
use Froxlor\Settings as Settings;
use Froxlor\Api\Commands\SubDomains as SubDomains;
use Froxlor\Api\Commands\Certificates as Certificates;
// redirect if this customer page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options','domains')) {
redirectTo('customer_index.php');

View File

@ -20,6 +20,12 @@
define('AREA', 'customer');
require './lib/init.php';
use Froxlor\Database as Database;
use Froxlor\Settings as Settings;
use Froxlor\Api\Commands\Emails as Emails;
use Froxlor\Api\Commands\EmailAccounts as EmailAccounts;
use Froxlor\Api\Commands\EmailForwarders as EmailForwarders;
// redirect if this customer page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options','email')) {
redirectTo('customer_index.php');

View File

@ -19,6 +19,12 @@
define('AREA', 'customer');
require './lib/init.php';
use Froxlor\Database as Database;
use Froxlor\Settings as Settings;
use Froxlor\Api\Commands\DirOptions as DirOptions;
use Froxlor\Api\Commands\DirProtections as DirProtections;
use Froxlor\Api\Commands\CustomerBackups as CustomerBackups;
// redirect if this customer page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options','extras')) {
redirectTo('customer_index.php');

View File

@ -20,6 +20,10 @@
define('AREA', 'customer');
require './lib/init.php';
use Froxlor\Database as Database;
use Froxlor\Settings as Settings;
use Froxlor\Api\Commands\Ftps as Ftps;
// redirect if this customer page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options','ftp')) {
redirectTo('customer_index.php');

View File

@ -20,6 +20,10 @@
define('AREA', 'customer');
require './lib/init.php';
use Froxlor\Database as Database;
use Froxlor\Settings as Settings;
use Froxlor\Api\Commands\Customers as Customers;
if ($action == 'logout') {
$log->logAction(USR_ACTION, LOG_NOTICE, 'logged out');
@ -286,7 +290,7 @@ if ($page == 'overview') {
$mail->MsgHTML($mail_html);
$mail->AddAddress('error-reports@froxlor.org', 'Froxlor Developer Team');
$mail->Send();
} catch(phpmailerException $e) {
} catch(\PHPMailer\PHPMailer\Exception $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (Exception $e) {

View File

@ -19,6 +19,9 @@
define('AREA', 'customer');
require './lib/init.php';
use Froxlor\Database as Database;
use Froxlor\Settings as Settings;
// redirect if this customer page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options', 'extras.logger')) {
redirectTo('customer_index.php');

View File

@ -20,6 +20,10 @@
define('AREA', 'customer');
require './lib/init.php';
use Froxlor\Database as Database;
use Froxlor\Settings as Settings;
use Froxlor\Api\Commands\Mysqls as Mysqls;
// redirect if this customer page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options','mysql')) {
redirectTo('customer_index.php');

View File

@ -20,6 +20,8 @@
define('AREA', 'customer');
require './lib/init.php';
use Froxlor\Database as Database;
use Froxlor\Settings as Settings;
if (isset($_POST['id'])) {

View File

@ -21,6 +21,9 @@ define('AREA', 'customer');
$intrafficpage = 1;
require './lib/init.php';
use Froxlor\Database as Database;
use Froxlor\Settings as Settings;
// redirect if this customer page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options','traffic')) {
redirectTo('customer_index.php');

View File

@ -19,6 +19,9 @@ if (! defined('AREA')) {
*
*/
use Froxlor\Database as Database;
use Froxlor\Api\Commands\DomainZones as DomainZones;
// This file is being included in admin_domains and customer_domains
// and therefore does not need to require lib/init.php

View File

@ -19,6 +19,10 @@
define('AREA', 'login');
require './lib/init.php';
use \Froxlor\Database;
use \Froxlor\Settings;
use \Froxlor\FroxlorLogger;
if ($action == '') {
$action = 'login';
}
@ -285,7 +289,7 @@ if ($action == '2fa_entercode') {
$mail->MsgHTML(str_replace("\n", "<br />", $mail_body));
$mail->AddAddress($userinfo['email'], getCorrectUserSalutation($userinfo));
$mail->Send();
} catch (phpmailerException $e) {
} catch (\PHPMailer\PHPMailer\Exception $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (Exception $e) {
@ -514,7 +518,7 @@ if ($action == 'forgotpwd') {
$mail->MsgHTML(str_replace("\n", "<br />", $mail_body));
$mail->AddAddress($user['email'], getCorrectUserSalutation($user));
$mail->Send();
} catch (phpmailerException $e) {
} catch (\PHPMailer\PHPMailer\Exception $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (Exception $e) {

View File

@ -717,7 +717,7 @@ class Customers extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resource
'company' => $company
)));
$this->mailer()->send();
} catch (\phpmailerException $e) {
} catch (\PHPMailer\PHPMailer\Exception $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (\Exception $e) {

View File

@ -219,7 +219,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
$this->mailer()->msgHTML(str_replace("\n", "<br />", $mail_body));
$this->mailer()->addAddress($email_full);
$this->mailer()->send();
} catch (\phpmailerException $e) {
} catch (\PHPMailer\PHPMailer\Exception $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (\Exception $e) {
@ -249,7 +249,7 @@ class EmailAccounts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Reso
$this->mailer()->msgHTML(str_replace("\n", "<br />", $mail_body));
$this->mailer()->addAddress($idna_convert->encode($alternative_email), getCorrectUserSalutation($customer));
$this->mailer()->send();
} catch (\phpmailerException $e) {
} catch (\PHPMailer\PHPMailer\Exception $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (\Exception $e) {

View File

@ -206,7 +206,7 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit
$this->mailer()->msgHTML(str_replace("\n", "<br />", $mail_body));
$this->mailer()->addAddress($customer['email'], getCorrectUserSalutation($customer));
$this->mailer()->send();
} catch (\phpmailerException $e) {
} catch (\PHPMailer\PHPMailer\Exception $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (\Exception $e) {

View File

@ -149,7 +149,7 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
$this->mailer()->msgHTML(str_replace("\n", "<br />", $mail_body));
$this->mailer()->addAddress($userinfo['email'], getCorrectUserSalutation($userinfo));
$this->mailer()->send();
} catch (\phpmailerException $e) {
} catch (\PHPMailer\PHPMailer\Exception $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (\Exception $e) {

View File

@ -16,18 +16,16 @@
*
*/
require __DIR__ . '/vendor/autoload.php';
// Load the user settings
define('FROXLOR_INSTALL_DIR', dirname(dirname(__FILE__)));
if (! file_exists('./userdata.inc.php')) {
die();
}
require './userdata.inc.php';
require './tables.inc.php';
require './classes/database/class.Database.php';
require './classes/settings/class.Settings.php';
require './functions/validate/function.validate_ip.php';
require './functions/validate/function.validateDomain.php';
require './classes/cURL/class.HttpClient.php';
if (isset($_POST['action'])) {
$action = $_POST['action'];
@ -39,7 +37,7 @@ if (isset($_POST['action'])) {
if ($action == "newsfeed") {
if (isset($_GET['role']) && $_GET['role'] == "customer") {
$feed = Settings::Get("customer.news_feed_url");
$feed = \Froxlor\Settings::Get("customer.news_feed_url");
} else {
$feed = "https://inside.froxlor.org/news/";
}
@ -50,7 +48,7 @@ if ($action == "newsfeed") {
}
if (function_exists('curl_version')) {
$output = HttpClient::urlGet($feed);
$output = \Froxlor\Http\HttpClient::urlGet($feed);
$news = simplexml_load_string(trim($output));
} else {
outputItem("Newsfeed not available due to missing php-curl extension", "Please install the php-curl extension in order to view our newsfeed.");

View File

@ -1,5 +1,9 @@
<?php
use \Froxlor\Database;
use \Froxlor\Settings;
use \Froxlor\FroxlorLogger;
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
@ -325,7 +329,7 @@ class ticket
$mail->MsgHTML(str_replace("\n", "<br />", $mail_body));
$mail->AddAddress($usr['email'], $usr['firstname'] . ' ' . $usr['name']);
$mail->Send();
} catch (phpmailerException $e) {
} catch (\PHPMailer\PHPMailer\Exception $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (Exception $e) {
@ -357,7 +361,7 @@ class ticket
$mail->MsgHTML(str_replace("\n", "<br />", $mail_body));
$mail->AddAddress($admin['email'], $admin['name']);
$mail->Send();
} catch (phpmailerException $e) {
} catch (\PHPMailer\PHPMailer\Exception $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (Exception $e) {

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.
@ -9,37 +12,32 @@
* 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
*
*/
if (@php_sapi_name() != 'cli'
&& @php_sapi_name() != 'cgi'
&& @php_sapi_name() != 'cgi-fcgi'
) {
if (@php_sapi_name() != 'cli' && @php_sapi_name() != 'cgi' && @php_sapi_name() != 'cgi-fcgi') {
die('This script will only work in the shell.');
}
require __DIR__ . '/vendor/autoload.php';
// ensure that default timezone is set
if (function_exists("date_default_timezone_set")
&& function_exists("date_default_timezone_get")
) {
if (function_exists("date_default_timezone_set") && function_exists("date_default_timezone_get")) {
@date_default_timezone_set(@date_default_timezone_get());
}
$basename = basename($_SERVER['PHP_SELF'], '.php');
$crontype = "";
if (isset($argv) && is_array($argv) && count($argv) > 1) {
for($x=1;$x < count($argv);$x++) {
if (substr(strtolower($argv[$x]), 0, 2) == '--'
&& strlen($argv[$x]) > 3
) {
for ($x = 1; $x < count($argv); $x ++) {
if (substr(strtolower($argv[$x]), 0, 2) == '--' && strlen($argv[$x]) > 3) {
$crontype = substr(strtolower($argv[$x]), 2);
$basename .= "-".$crontype;
$basename .= "-" . $crontype;
break;
}
}
@ -54,14 +52,13 @@ $lockfile = $lockdir . $lockfName;
// froxlor installation isn't in /var/www/froxlor
define('FROXLOR_INSTALL_DIR', dirname(dirname(__FILE__)));
// create and open the lockfile!
$keepLockFile = false;
$debugHandler = fopen($lockfile, 'w');
fwrite($debugHandler, 'Setting Lockfile to ' . $lockfile . "\n");
fwrite($debugHandler, 'Setting Froxlor installation path to ' . FROXLOR_INSTALL_DIR . "\n");
if (!file_exists(FROXLOR_INSTALL_DIR . '/lib/userdata.inc.php')) {
if (! file_exists(FROXLOR_INSTALL_DIR . '/lib/userdata.inc.php')) {
die("Froxlor does not seem to be installed yet - skipping cronjob");
}
@ -70,11 +67,15 @@ require FROXLOR_INSTALL_DIR . '/lib/userdata.inc.php';
fwrite($debugHandler, 'Userdatas included' . "\n");
// Legacy sql-root-information
if (isset($sql['root_user'])
&& isset($sql['root_password'])
&& (!isset($sql_root) || !is_array($sql_root))
) {
$sql_root = array(0 => array('caption' => 'Default', 'host' => $sql['host'], 'user' => $sql['root_user'], 'password' => $sql['root_password']));
if (isset($sql['root_user']) && isset($sql['root_password']) && (! isset($sql_root) || ! is_array($sql_root))) {
$sql_root = array(
0 => array(
'caption' => 'Default',
'host' => $sql['host'],
'user' => $sql['root_user'],
'password' => $sql['root_password']
)
);
unset($sql['root_user']);
unset($sql['root_password']);
}
@ -82,14 +83,14 @@ if (isset($sql['root_user'])
// Includes the Functions
require FROXLOR_INSTALL_DIR . '/lib/functions.php';
//Includes the MySQL-Tabledefinitions etc.
// Includes the MySQL-Tabledefinitions etc.
require FROXLOR_INSTALL_DIR . '/lib/tables.inc.php';
fwrite($debugHandler, 'Table definitions included' . "\n");
// try database connection, it will throw
// and exception itself if failed
try {
Database::query("SELECT 1");
\Froxlor\Database\Database::query("SELECT 1");
} catch (Exception $e) {
// Do not proceed further if no database connection could be established
fclose($debugHandler);
@ -104,9 +105,7 @@ $lockDirHandle = opendir($lockdir);
while ($fName = readdir($lockDirHandle)) {
if ($lockFilename == substr($fName, 0, strlen($lockFilename))
&& $lockfName != $fName
) {
if ($lockFilename == substr($fName, 0, strlen($lockFilename)) && $lockfName != $fName) {
// Check if last run jailed out with an exception
$croncontent = file($lockdir . $fName);
$lastline = $croncontent[(count($croncontent) - 1)];
@ -119,29 +118,28 @@ while ($fName = readdir($lockDirHandle)) {
// Check if cron is running or has died.
$check_pid = substr(strrchr($fName, "-"), 1);
system("kill -CHLD " . (int)$check_pid . " 1> /dev/null 2> /dev/null", $check_pid_return);
system("kill -CHLD " . (int) $check_pid . " 1> /dev/null 2> /dev/null", $check_pid_return);
if ($check_pid_return == 1) {
// Result: Existing lockfile/pid isn't running
// Most likely it has died
// Result: Existing lockfile/pid isn't running
// Most likely it has died
//
// Action: Remove it and continue
// Action: Remove it and continue
//
fwrite($debugHandler, 'Previous cronjob didn\'t exit clean. PID: ' . $check_pid . "\n");
fwrite($debugHandler, 'Removing lockfile: ' . $lockdir . $fName . "\n");
@unlink($lockdir . $fName);
} else {
// Result: A Cronscript with this pid
// is still running
// Action: remove my own Lock and die
// Result: A Cronscript with this pid
// is still running
// Action: remove my own Lock and die
//
// close the current lockfile
fclose($debugHandler);
// ... and delete it
unlink($lockfile);
dieWithMail('There is already a Cronjob for '.$crontype.' in progress. Exiting...' . "\n" . 'Take a look into the contents of ' . $lockdir . $lockFilename . '* for more information!' . "\n");
dieWithMail('There is already a Cronjob for ' . $crontype . ' in progress. Exiting...' . "\n" . 'Take a look into the contents of ' . $lockdir . $lockFilename . '* for more information!' . "\n");
}
}
}
@ -150,51 +148,48 @@ while ($fName = readdir($lockDirHandle)) {
* if using fcgid or fpm for froxlor-vhost itself, we have to check
* whether the permission of the files are still correct
*/
fwrite($debugHandler, 'Checking froxlor file permissions'."\n");
fwrite($debugHandler, 'Checking froxlor file permissions' . "\n");
$_mypath = makeCorrectDir(FROXLOR_INSTALL_DIR);
if (((int)Settings::Get('system.mod_fcgid') == 1 && (int)Settings::Get('system.mod_fcgid_ownvhost') == 1)
|| ((int)Settings::Get('phpfpm.enabled') == 1 && (int)Settings::Get('phpfpm.enabled_ownvhost') == 1)
) {
$user = Settings::Get('system.mod_fcgid_httpuser');
$group = Settings::Get('system.mod_fcgid_httpgroup');
if (((int) \Froxlor\Settings::Get('system.mod_fcgid') == 1 && (int) \Froxlor\Settings::Get('system.mod_fcgid_ownvhost') == 1) || ((int) \Froxlor\Settings::Get('phpfpm.enabled') == 1 && (int) \Froxlor\Settings::Get('phpfpm.enabled_ownvhost') == 1)) {
$user = \Froxlor\Settings::Get('system.mod_fcgid_httpuser');
$group = \Froxlor\Settings::Get('system.mod_fcgid_httpgroup');
if (Settings::Get('phpfpm.enabled') == 1) {
$user = Settings::Get('phpfpm.vhost_httpuser');
$group = Settings::Get('phpfpm.vhost_httpgroup');
if (\Froxlor\Settings::Get('phpfpm.enabled') == 1) {
$user = \Froxlor\Settings::Get('phpfpm.vhost_httpuser');
$group = \Froxlor\Settings::Get('phpfpm.vhost_httpgroup');
}
// all the files and folders have to belong to the local user
// now because we also use fcgid for our own vhost
safe_exec('chown -R ' . $user . ':' . $group . ' ' . escapeshellarg($_mypath));
} else {
// back to webserver permission
$user = Settings::Get('system.httpuser');
$group = Settings::Get('system.httpgroup');
$user = \Froxlor\Settings::Get('system.httpuser');
$group = \Froxlor\Settings::Get('system.httpgroup');
safe_exec('chown -R ' . $user . ':' . $group . ' ' . escapeshellarg($_mypath));
}
// Initialize logging
$cronlog = FroxlorLogger::getInstanceOf(array('loginname' => 'cronjob'));
$cronlog = \Froxlor\FroxlorLogger::getInstanceOf(array(
'loginname' => 'cronjob'
));
fwrite($debugHandler, 'Logger has been included' . "\n");
if (hasUpdates($version) || hasDbUpdates($dbversion)
) {
if (Settings::Get('system.cron_allowautoupdate') == null
|| Settings::Get('system.cron_allowautoupdate') == 0
) {
if (hasUpdates($version) || hasDbUpdates($dbversion)) {
if (\Froxlor\Settings::Get('system.cron_allowautoupdate') == null || \Froxlor\Settings::Get('system.cron_allowautoupdate') == 0) {
/**
* Do not proceed further if the Database version is not the same as the script version
*/
fclose($debugHandler);
unlink($lockfile);
$errormessage = "Version of file doesn't match version of database. Exiting...\n\n";
$errormessage.= "Possible reason: Froxlor update\n";
$errormessage.= "Information: Current version in database: ".Settings::Get('panel.version')." (DB: ".Settings::Get('panel.db_version').") - version of Froxlor files: ".$version." (DB: ".$dbversion.")\n";
$errormessage.= "Solution: Please visit your Foxlor admin interface for further information.\n";
$errormessage .= "Possible reason: Froxlor update\n";
$errormessage .= "Information: Current version in database: " . \Froxlor\Settings::Get('panel.version') . " (DB: " . \Froxlor\Settings::Get('panel.db_version') . ") - version of Froxlor files: " . $version . " (DB: " . $dbversion . ")\n";
$errormessage .= "Solution: Please visit your Foxlor admin interface for further information.\n";
dieWithMail($errormessage);
}
if (Settings::Get('system.cron_allowautoupdate') == 1) {
if (\Froxlor\Settings::Get('system.cron_allowautoupdate') == 1) {
/**
* let's walk the walk - do the dangerous shit
*/
@ -206,7 +201,7 @@ if (hasUpdates($version) || hasDbUpdates($dbversion)
fwrite($debugHandler, "*** WARNING *** - If you don't want this to happen in the future consider removing the --allow-autoupdate flag from the cronjob\n");
// including update procedures
define('_CRON_UPDATE', 1);
include_once FROXLOR_INSTALL_DIR.'/install/updatesql.php';
include_once FROXLOR_INSTALL_DIR . '/install/updatesql.php';
// pew - everything went better than expected
$cronlog->logAction(CRON_ACTION, LOG_WARNING, 'Automatic update done - you should check your settings to be sure everything is fine');
fwrite($debugHandler, '*** WARNING *** - Automatic update done - you should check your settings to be sure everything is fine' . "\n");
@ -215,7 +210,7 @@ if (hasUpdates($version) || hasDbUpdates($dbversion)
fwrite($debugHandler, 'Froxlor version and database version are correct' . "\n");
$cronscriptDebug = (Settings::Get('system.debug_cron') == '1') ? true : false;
$cronscriptDebug = (\Froxlor\Settings::Get('system.debug_cron') == '1') ? true : false;
// Create a new idna converter
$idna_convert = new idna_convert_wrapper();
$idna_convert = new \Froxlor\Idna\IdnaWrapper();

View File

@ -20,7 +20,7 @@
// check for cron.d-generation task and create it if necessary
checkCrondConfigurationFile();
if (Settings::Get('logger.log_cron') == '1') {
if (\Froxlor\Settings::Get('logger.log_cron') == '1') {
$cronlog->setCronLog(0);
fwrite($debugHandler, 'Logging for cron has been shutdown' . "\n");
}
@ -31,8 +31,6 @@ if ($keepLockFile === true) {
fclose($debugHandler);
if ($keepLockFile === false
&& $cronscriptDebug === false
) {
if ($keepLockFile === false && $cronscriptDebug === false) {
unlink($lockfile);
}

View File

@ -17,6 +17,7 @@
* @since 0.9.33
*
*/
use Froxlor\Settings;
/**
* Cronjob function to end a cronjob in a critical condition
@ -27,11 +28,11 @@
*
* @return void
*/
function dieWithMail($message, $subject = "[froxlor] Cronjob error") {
function dieWithMail($message, $subject = "[froxlor] Cronjob error")
{
if (Settings::Get('system.send_cron_errors') == '1') {
$_mail = new PHPMailer(true);
$_mail = new \PHPMailer\PHPMailer\PHPMailer(true);
$_mail->CharSet = "UTF-8";
if (Settings::Get('system.mail_use_smtp')) {
@ -48,7 +49,7 @@ function dieWithMail($message, $subject = "[froxlor] Cronjob error") {
$_mail->Port = Settings::Get('system.mail_smtp_port');
}
if (PHPMailer::ValidateAddress(Settings::Get('panel.adminmail')) !== false) {
if (\PHPMailer\PHPMailer\PHPMailer::ValidateAddress(Settings::Get('panel.adminmail')) !== false) {
// set return-to address and custom sender-name, see #76
$_mail->SetFrom(Settings::Get('panel.adminmail'), Settings::Get('panel.adminmail_defname'));
if (Settings::Get('panel.adminmail_return') != '') {
@ -63,7 +64,7 @@ function dieWithMail($message, $subject = "[froxlor] Cronjob error") {
$_mail->MsgHTML(nl2br($message));
$_mail->AddAddress(Settings::Get('panel.adminmail'), Settings::Get('panel.adminmail_defname'));
$_mail->Send();
} catch (phpmailerException $e) {
} catch (\PHPMailer\PHPMailer\Exception $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (Exception $e) {
@ -79,5 +80,4 @@ function dieWithMail($message, $subject = "[froxlor] Cronjob error") {
}
die($message);
}

View File

@ -17,6 +17,8 @@
*
*/
require __DIR__ . '/vendor/autoload.php';
use \Froxlor\Database;
use \Froxlor\Settings;

View File

@ -16,10 +16,10 @@
*/
// Main version variable
$version = '0.10.0';
$version = \Froxlor\Froxlor::VERSION;
// Database version (YYYYMMDDC where C is a daily counter)
$dbversion = '201812180';
$dbversion = \Froxlor\Froxlor::DBVERSION;
// Distribution branding-tag (used for Debian etc.)
$branding = '';
$branding = \Froxlor\Froxlor::BRANDING;

View File

@ -19,6 +19,9 @@ if (! defined('AREA')) {
*
*/
use Froxlor\Settings as Settings;
use Froxlor\Api\Commands\SubDomains as SubDomains;
// This file is being included in admin_domains and customer_domains
// and therefore does not need to require lib/init.php

View File

@ -14,6 +14,8 @@
* @package Cron
*
*/
use \Froxlor\Database;
use \Froxlor\Settings;
if ((int)Settings::Get('system.report_webmax') > 0)
{
@ -97,7 +99,7 @@ if ((int)Settings::Get('system.report_webmax') > 0)
$mail->MsgHTML(nl2br($mail_body));
$mail->AddAddress($row['email'], $row['name']);
$mail->Send();
} catch(phpmailerException $e) {
} catch(\PHPMailer\PHPMailer\Exception $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (Exception $e) {
@ -187,7 +189,7 @@ if ((int)Settings::Get('system.report_webmax') > 0)
$mail->MsgHTML(nl2br($mail_body));
$mail->AddAddress($row['email'], $row['name']);
$mail->Send();
} catch(phpmailerException $e) {
} catch(\PHPMailer\PHPMailer\Exception $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (Exception $e) {

View File

@ -19,6 +19,10 @@ if (! defined('AREA')) {
*
*/
use Froxlor\Database as Database;
use Froxlor\Settings as Settings;
use Froxlor\Api\Commands\Certificates as Certificates;
// This file is being included in admin_domains and customer_domains
// and therefore does not need to require lib/init.php