various minor bugfixes; composer requirements update
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -105,7 +105,7 @@ abstract class ApiCommand extends ApiParameter
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct($header = null, $params = null, $userinfo = null, $internal = false)
|
||||
final public function __construct($header = null, $params = null, $userinfo = null, $internal = false)
|
||||
{
|
||||
parent::__construct($params);
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ class Admins extends ApiCommand implements ResourceEntity
|
||||
* returns the total number of admins for the given admin
|
||||
*
|
||||
* @access admin
|
||||
* @return string json-encoded array
|
||||
* @return string json-encoded response message
|
||||
* @throws Exception
|
||||
*/
|
||||
public function listingCount()
|
||||
@@ -131,6 +131,7 @@ class Admins extends ApiCommand implements ResourceEntity
|
||||
if ($result) {
|
||||
return $this->response($result['num_admins']);
|
||||
}
|
||||
$this->response(0);
|
||||
}
|
||||
throw new Exception("Not allowed to execute given command.", 403);
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ class Certificates extends ApiCommand implements ResourceEntity
|
||||
* returns the total number of certificates for the given user
|
||||
*
|
||||
* @access admin, customer
|
||||
* @return string json-encoded array
|
||||
* @return string json-encoded response message
|
||||
* @throws Exception
|
||||
*/
|
||||
public function listingCount()
|
||||
@@ -399,6 +399,7 @@ class Certificates extends ApiCommand implements ResourceEntity
|
||||
if ($result) {
|
||||
return $this->response($result['num_certs']);
|
||||
}
|
||||
return $this->response(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -185,7 +185,7 @@ class Cronjobs extends ApiCommand implements ResourceEntity
|
||||
* returns the total number of cronjobs
|
||||
*
|
||||
* @access admin
|
||||
* @return string json-encoded array
|
||||
* @return string json-encoded response message
|
||||
* @throws Exception
|
||||
*/
|
||||
public function listingCount()
|
||||
@@ -198,6 +198,7 @@ class Cronjobs extends ApiCommand implements ResourceEntity
|
||||
if ($result) {
|
||||
return $this->response($result['num_crons']);
|
||||
}
|
||||
return $this->response(0);
|
||||
}
|
||||
throw new Exception("Not allowed to execute given command.", 403);
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ class CustomerBackups extends ApiCommand implements ResourceEntity
|
||||
* optional, admin-only, select backup-jobs of a specific customer by loginname
|
||||
*
|
||||
* @access admin, customer
|
||||
* @return string json-encoded array
|
||||
* @return string json-encoded response message
|
||||
* @throws Exception
|
||||
*/
|
||||
public function listingCount()
|
||||
|
||||
@@ -143,7 +143,7 @@ class Customers extends ApiCommand implements ResourceEntity
|
||||
* returns the total number of customers for the given admin
|
||||
*
|
||||
* @access admin
|
||||
* @return string json-encoded array
|
||||
* @return string json-encoded response message
|
||||
* @throws Exception
|
||||
*/
|
||||
public function listingCount()
|
||||
@@ -163,6 +163,7 @@ class Customers extends ApiCommand implements ResourceEntity
|
||||
if ($result) {
|
||||
return $this->response($result['num_customers']);
|
||||
}
|
||||
return $this->response(0);
|
||||
}
|
||||
throw new Exception("Not allowed to execute given command.", 403);
|
||||
}
|
||||
|
||||
@@ -396,7 +396,7 @@ class DirOptions extends ApiCommand implements ResourceEntity
|
||||
* optional, admin-only, select directory-protections of a specific customer by loginname
|
||||
*
|
||||
* @access admin, customer
|
||||
* @return string json-encoded array count|list
|
||||
* @return string json-encoded response message
|
||||
* @throws Exception
|
||||
*/
|
||||
public function listingCount()
|
||||
@@ -415,6 +415,7 @@ class DirOptions extends ApiCommand implements ResourceEntity
|
||||
if ($result) {
|
||||
return $this->response($result['num_htaccess']);
|
||||
}
|
||||
return $this->response(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -339,7 +339,7 @@ class DirProtections extends ApiCommand implements ResourceEntity
|
||||
* optional, admin-only, select directory-protections of a specific customer by loginname
|
||||
*
|
||||
* @access admin, customer
|
||||
* @return string json-encoded array count|list
|
||||
* @return string json-encoded response message
|
||||
* @throws Exception
|
||||
*/
|
||||
public function listingCount()
|
||||
@@ -358,6 +358,7 @@ class DirProtections extends ApiCommand implements ResourceEntity
|
||||
if ($result) {
|
||||
return $this->response($result['num_htpasswd']);
|
||||
}
|
||||
return $this->response(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -491,7 +491,7 @@ class DomainZones extends ApiCommand implements ResourceEntity
|
||||
* optional, the domain name
|
||||
*
|
||||
* @access admin, customer
|
||||
* @return bool
|
||||
* @return string json-encoded response message
|
||||
* @throws Exception
|
||||
*/
|
||||
public function listingCount()
|
||||
@@ -522,6 +522,7 @@ class DomainZones extends ApiCommand implements ResourceEntity
|
||||
if ($result) {
|
||||
return $this->response($result['num_dns']);
|
||||
}
|
||||
return $this->response(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1743,9 +1743,6 @@ class Domains extends ApiCommand implements ResourceEntity
|
||||
$upd_specialsettings = ", `specialsettings` = :specialsettings, `ssl_specialsettings` = :ssl_specialsettings, `include_specialsettings` = :include_specialsettings ";
|
||||
} else {
|
||||
$upd_specialsettings = '';
|
||||
unset($_update_data['specialsettings']);
|
||||
unset($_update_data['ssl_specialsettings']);
|
||||
unset($_update_data['include_specialsettings']);
|
||||
$upd_stmt = Database::prepare("
|
||||
UPDATE `" . TABLE_PANEL_DOMAINS . "` SET `specialsettings`='', `ssl_specialsettings`='', `include_specialsettings`='0' WHERE `parentdomainid` = :id
|
||||
");
|
||||
|
||||
@@ -216,7 +216,6 @@ class EmailAccounts extends ApiCommand implements ResourceEntity
|
||||
// replacer array for mail to create account on server
|
||||
$replace_arr = [
|
||||
'EMAIL' => $email_full,
|
||||
'USERNAME' => $username,
|
||||
'PASSWORD' => htmlentities(htmlentities($password)),
|
||||
'SALUTATION' => User::getCorrectUserSalutation($customer),
|
||||
'NAME' => $customer['name'],
|
||||
|
||||
@@ -206,7 +206,7 @@ class EmailForwarders extends ApiCommand implements ResourceEntity
|
||||
* optional, admin-only, the loginname
|
||||
*
|
||||
* @access admin,customer
|
||||
* @return string json-encoded array
|
||||
* @return string json-encoded response message
|
||||
* @throws Exception
|
||||
*/
|
||||
public function listingCount()
|
||||
|
||||
@@ -356,7 +356,7 @@ class Emails extends ApiCommand implements ResourceEntity
|
||||
* optional, admin-only, select email addresses of a specific customer by loginname
|
||||
*
|
||||
* @access admin, customer
|
||||
* @return string json-encoded array
|
||||
* @return string json-encoded response message
|
||||
* @throws Exception
|
||||
*/
|
||||
public function listingCount()
|
||||
@@ -373,6 +373,7 @@ class Emails extends ApiCommand implements ResourceEntity
|
||||
if ($result) {
|
||||
return $this->response($result['num_emails']);
|
||||
}
|
||||
return $this->response(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -105,7 +105,7 @@ class FpmDaemons extends ApiCommand implements ResourceEntity
|
||||
* returns the total number of accessible fpm daemons
|
||||
*
|
||||
* @access admin
|
||||
* @return string json-encoded array
|
||||
* @return string json-encoded response message
|
||||
* @throws Exception
|
||||
*/
|
||||
public function listingCount()
|
||||
@@ -118,6 +118,7 @@ class FpmDaemons extends ApiCommand implements ResourceEntity
|
||||
if ($result) {
|
||||
return $this->response($result['num_fpms']);
|
||||
}
|
||||
return $this->response(0);
|
||||
}
|
||||
throw new Exception("Not allowed to execute given command.", 403);
|
||||
}
|
||||
|
||||
@@ -549,7 +549,7 @@ class Ftps extends ApiCommand implements ResourceEntity
|
||||
* optional, admin-only, select ftp-users of a specific customer by loginname
|
||||
*
|
||||
* @access admin, customer
|
||||
* @return string json-encoded array
|
||||
* @return string json-encoded response message
|
||||
* @throws Exception
|
||||
*/
|
||||
public function listingCount()
|
||||
@@ -564,6 +564,7 @@ class Ftps extends ApiCommand implements ResourceEntity
|
||||
if ($result) {
|
||||
return $this->response($result['num_ftps']);
|
||||
}
|
||||
return $this->response(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -89,7 +89,7 @@ class HostingPlans extends ApiCommand implements ResourceEntity
|
||||
* returns the total number of accessible hosting plans
|
||||
*
|
||||
* @access admin
|
||||
* @return string json-encoded array
|
||||
* @return string json-encoded response message
|
||||
* @throws Exception
|
||||
*/
|
||||
public function listingCount()
|
||||
@@ -107,6 +107,7 @@ class HostingPlans extends ApiCommand implements ResourceEntity
|
||||
if ($result) {
|
||||
return $this->response($result['num_plans']);
|
||||
}
|
||||
return $this->response(0);
|
||||
}
|
||||
throw new Exception("Not allowed to execute given command.", 403);
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ class IpsAndPorts extends ApiCommand implements ResourceEntity
|
||||
* returns the total number of accessible ip/port entries
|
||||
*
|
||||
* @access admin
|
||||
* @return string json-encoded array
|
||||
* @return string json-encoded response message
|
||||
* @throws Exception
|
||||
*/
|
||||
public function listingCount()
|
||||
@@ -108,6 +108,7 @@ class IpsAndPorts extends ApiCommand implements ResourceEntity
|
||||
if ($result) {
|
||||
return $this->response($result['num_ips']);
|
||||
}
|
||||
return $this->response(0);
|
||||
}
|
||||
throw new Exception("Not allowed to execute given command.", 403);
|
||||
}
|
||||
|
||||
@@ -124,6 +124,9 @@ class MysqlServer extends ApiCommand implements ResourceEntity
|
||||
}
|
||||
}
|
||||
|
||||
$sql = [];
|
||||
$sql_root = [];
|
||||
|
||||
// get all data from lib/userdata
|
||||
require Froxlor::getInstallDir() . "/lib/userdata.inc.php";
|
||||
|
||||
@@ -222,6 +225,8 @@ class MysqlServer extends ApiCommand implements ResourceEntity
|
||||
*/
|
||||
public function listing()
|
||||
{
|
||||
$sql = [];
|
||||
$sql_root = [];
|
||||
// get all data from lib/userdata
|
||||
require Froxlor::getInstallDir() . "/lib/userdata.inc.php";
|
||||
|
||||
@@ -255,7 +260,7 @@ class MysqlServer extends ApiCommand implements ResourceEntity
|
||||
* returns the total number of mysql servers
|
||||
*
|
||||
* @access admin, customer
|
||||
* @return string json-encoded array
|
||||
* @return string json-encoded response message
|
||||
*/
|
||||
public function listingCount()
|
||||
{
|
||||
@@ -266,6 +271,7 @@ class MysqlServer extends ApiCommand implements ResourceEntity
|
||||
}
|
||||
return $this->response(0);
|
||||
}
|
||||
$sql_root = [];
|
||||
// get all data from lib/userdata
|
||||
require Froxlor::getInstallDir() . "/lib/userdata.inc.php";
|
||||
return $this->response(count($sql_root));
|
||||
@@ -290,9 +296,14 @@ class MysqlServer extends ApiCommand implements ResourceEntity
|
||||
$dbserver = (int) $this->getParam('dbserver', $dn_optional, -1);
|
||||
$dbserver = $id >= 0 ? $id : $dbserver;
|
||||
|
||||
$sql_root = [];
|
||||
// get all data from lib/userdata
|
||||
require Froxlor::getInstallDir() . "/lib/userdata.inc.php";
|
||||
|
||||
if (!isset($sql_root[$dbserver])) {
|
||||
throw new Exception('Mysql server not found', 404);
|
||||
}
|
||||
|
||||
// limit customer to its allowed servers
|
||||
if ($this->isAdmin() == false) {
|
||||
$allowed_mysqls = json_decode($this->getUserDetail('allowed_mysqlserver'), true);
|
||||
@@ -300,11 +311,7 @@ class MysqlServer extends ApiCommand implements ResourceEntity
|
||||
throw new Exception("You cannot access this resource", 405);
|
||||
}
|
||||
// no usernames required for non-admins
|
||||
unset($sqlrootdata['user']);
|
||||
}
|
||||
|
||||
if (!isset($sql_root[$dbserver])) {
|
||||
throw new Exception('Mysql server not found', 404);
|
||||
unset($sql_root[$dbserver]['user']);
|
||||
}
|
||||
|
||||
unset($sql_root[$dbserver]['password']);
|
||||
|
||||
@@ -481,7 +481,7 @@ class Mysqls extends ApiCommand implements ResourceEntity
|
||||
* optional, admin-only, select dbs of a specific customer by loginname
|
||||
*
|
||||
* @access admin, customer
|
||||
* @return string json-encoded array
|
||||
* @return string json-encoded response message
|
||||
* @throws Exception
|
||||
*/
|
||||
public function listingCount()
|
||||
@@ -495,6 +495,7 @@ class Mysqls extends ApiCommand implements ResourceEntity
|
||||
if ($result) {
|
||||
return $this->response($result['num_dbs']);
|
||||
}
|
||||
return $this->response(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -178,7 +178,7 @@ class PhpSettings extends ApiCommand implements ResourceEntity
|
||||
* returns the total number of accessible php-setting entries
|
||||
*
|
||||
* @access admin
|
||||
* @return string json-encoded array
|
||||
* @return string json-encoded response message
|
||||
* @throws Exception
|
||||
*/
|
||||
public function listingCount()
|
||||
@@ -192,6 +192,7 @@ class PhpSettings extends ApiCommand implements ResourceEntity
|
||||
if ($result) {
|
||||
return $this->response($result['num_phps']);
|
||||
}
|
||||
return $this->response(0);
|
||||
}
|
||||
throw new Exception("Not allowed to execute given command.", 403);
|
||||
}
|
||||
|
||||
@@ -1017,7 +1017,7 @@ class SubDomains extends ApiCommand implements ResourceEntity
|
||||
* optional, admin-only, select (sub)domains of a specific customer by loginname
|
||||
*
|
||||
* @access admin, customer
|
||||
* @return string json-encoded array
|
||||
* @return string json-encoded response message
|
||||
* @throws Exception
|
||||
*/
|
||||
public function listingCount()
|
||||
@@ -1069,6 +1069,7 @@ class SubDomains extends ApiCommand implements ResourceEntity
|
||||
if ($result) {
|
||||
return $this->response($result['num_subdom']);
|
||||
}
|
||||
return $this->response(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -103,7 +103,7 @@ class SysLog extends ApiCommand implements ResourceEntity
|
||||
* returns the total number of log-entries
|
||||
*
|
||||
* @access admin
|
||||
* @return string json-encoded array
|
||||
* @return string json-encoded response message
|
||||
* @throws Exception
|
||||
*/
|
||||
public function listingCount()
|
||||
@@ -150,6 +150,7 @@ class SysLog extends ApiCommand implements ResourceEntity
|
||||
if ($result) {
|
||||
return $this->response($result['num_logs']);
|
||||
}
|
||||
return $this->response(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -76,7 +76,7 @@ abstract class BulkAction
|
||||
*
|
||||
* @return object BulkAction instance
|
||||
*/
|
||||
protected function __construct($import_file = null, $userinfo = [])
|
||||
protected function __construct(string $import_file = null, array $userinfo = [])
|
||||
{
|
||||
if (!empty($import_file)) {
|
||||
$this->impFile = FileDir::makeCorrectFile($import_file);
|
||||
@@ -93,7 +93,7 @@ abstract class BulkAction
|
||||
*
|
||||
* @return array 'all' => amount of records processed, 'imported' => number of imported records
|
||||
*/
|
||||
abstract public function doImport($separator = ";", $offset = 0);
|
||||
abstract public function doImport(string $separator = ";", int $offset = 0);
|
||||
|
||||
/**
|
||||
* setter for import-file
|
||||
|
||||
@@ -34,10 +34,12 @@ class DomainBulkAction extends BulkAction
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $import_file
|
||||
* @param array $userinfo
|
||||
*
|
||||
* @return object DomainBulkAction instance
|
||||
* @return DomainBulkAction
|
||||
*/
|
||||
public function __construct($import_file = null, $userinfo)
|
||||
public function __construct(string $import_file = null, array $userinfo = [])
|
||||
{
|
||||
parent::__construct($import_file, $userinfo);
|
||||
$this->setApiCall('Domains.add');
|
||||
@@ -52,7 +54,7 @@ class DomainBulkAction extends BulkAction
|
||||
*
|
||||
* @return array 'all' => amount of records processed, 'imported' => number of imported records
|
||||
*/
|
||||
public function doImport($separator = ";", $offset = 0)
|
||||
public function doImport(string $separator = ";", int $offset = 0)
|
||||
{
|
||||
if ($this->userinfo['domains'] == "-1") {
|
||||
$dom_unlimited = true;
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace Froxlor\Cli;
|
||||
use Exception;
|
||||
use Froxlor\Froxlor;
|
||||
use Froxlor\Settings;
|
||||
use Froxlor\Database\Database;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
@@ -72,7 +73,7 @@ class CliCommand extends Command
|
||||
include_once Froxlor::getInstallDir() . '/install/updatesql.php';
|
||||
ob_end_flush();
|
||||
$output->writeln('<info>Automatic update done - you should check your settings to be sure everything is fine</>');
|
||||
return self::SUCCCESS;
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
private function cleanUpdateOutput($buffer)
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
namespace Froxlor\Cli;
|
||||
|
||||
use PDO;
|
||||
use Froxlor\Froxlor;
|
||||
use Froxlor\FileDir;
|
||||
use Froxlor\Settings;
|
||||
@@ -32,6 +33,7 @@ use Froxlor\FroxlorLogger;
|
||||
use Froxlor\Database\Database;
|
||||
use Froxlor\System\Cronjob;
|
||||
use Froxlor\Cron\TaskId;
|
||||
use Froxlor\Cron\CronConfig;
|
||||
use Froxlor\Cron\System\Extrausers;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
@@ -142,7 +144,7 @@ final class MasterCron extends CliCommand
|
||||
// we have to check the system's last guid with every cron run
|
||||
// in case the admin installed new software which added a new user
|
||||
//so users in the database don't conflict with system users
|
||||
$this->cronlog->logAction(FroxlorLogger::CRON_ACTION, LOG_NOTICE, 'Checking system\'s last guid');
|
||||
$this->cronLog->logAction(FroxlorLogger::CRON_ACTION, LOG_NOTICE, 'Checking system\'s last guid');
|
||||
Cronjob::checkLastGuid();
|
||||
|
||||
// check for cron.d-generation task and create it if necessary
|
||||
@@ -160,7 +162,7 @@ final class MasterCron extends CliCommand
|
||||
{
|
||||
if ($jobcount > 0) {
|
||||
if (Settings::Get('system.nssextrausers') == 1) {
|
||||
Extrausers::generateFiles(self::$cronlog);
|
||||
Extrausers::generateFiles($this->cronLog);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ final class UpdateCommand extends CliCommand
|
||||
$auex = AutoUpdate::extractZip($audl);
|
||||
if ($auex == 0) {
|
||||
$output->writeln("<info>Froxlor files updated successfully.</>");
|
||||
$result = self::SUCCCESS;
|
||||
$result = self::SUCCESS;
|
||||
$question = new ConfirmationQuestion('Update database? [no] ', false, '/^(y|j)/i');
|
||||
if ($yestoall || $helper->ask($input, $output, $question)) {
|
||||
$result = $this->updateDatabase();
|
||||
@@ -193,7 +193,7 @@ final class UpdateCommand extends CliCommand
|
||||
]);
|
||||
include_once Froxlor::getInstallDir() . '/install/updatesql.php';
|
||||
ob_end_flush();
|
||||
return self::SUCCCESS;
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
private function cleanUpdateOutput($buffer)
|
||||
|
||||
@@ -127,6 +127,8 @@ class ConfigDaemon
|
||||
if (is_null($this->sqldata_cache)) {
|
||||
// read in sql-data (if exists)
|
||||
if (file_exists(Froxlor::getInstallDir() . "/lib/userdata.inc.php")) {
|
||||
$sql = [];
|
||||
$sql_root = [];
|
||||
require Froxlor::getInstallDir() . "/lib/userdata.inc.php";
|
||||
unset($sql_root);
|
||||
$this->sqldata_cache = $sql;
|
||||
|
||||
@@ -40,16 +40,10 @@ use Froxlor\Validate\Validate;
|
||||
use Froxlor\System\Crypt;
|
||||
use PDO;
|
||||
|
||||
/**
|
||||
* @author Florian Lippert <flo@syscp.org> (2003-2009)
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
*/
|
||||
class Apache extends HttpConfigBase
|
||||
{
|
||||
|
||||
// protected
|
||||
protected $known_vhostfilenames = [];
|
||||
|
||||
protected $known_diroptionsfilenames = [];
|
||||
|
||||
protected $known_htpasswdsfilenames = [];
|
||||
@@ -1460,8 +1454,6 @@ class Apache extends HttpConfigBase
|
||||
|
||||
// Write a single file for every vhost
|
||||
foreach ($this->virtualhosts_data as $vhosts_filename => $vhosts_file) {
|
||||
$this->known_vhostfilenames[] = basename($vhosts_filename);
|
||||
|
||||
// Apply header
|
||||
$vhosts_file = '# ' . basename($vhosts_filename) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n" . "\n" . $vhosts_file;
|
||||
$vhosts_file_handler = fopen($vhosts_filename, 'w');
|
||||
|
||||
@@ -65,10 +65,10 @@ class AcmeSh extends FroxlorCron
|
||||
/**
|
||||
* run the task
|
||||
*
|
||||
* @param boolean $internal
|
||||
* @param bool $internal
|
||||
* @return number
|
||||
*/
|
||||
public static function run($internal = false)
|
||||
public static function run(bool $internal = false)
|
||||
{
|
||||
// usually, this is action is called from within the tasks-jobs
|
||||
if (!defined('CRON_IS_FORCED') && !defined('CRON_DEBUG_FLAG') && $internal == false) {
|
||||
@@ -201,6 +201,7 @@ class AcmeSh extends FroxlorCron
|
||||
} else {
|
||||
FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_INFO, "No new certificates or certificate updates found");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,6 +29,7 @@ use Froxlor\Cron\Http\Php\PhpInterface;
|
||||
use Froxlor\Customer\Customer;
|
||||
use Froxlor\Database\Database;
|
||||
use Froxlor\Domain\Domain;
|
||||
use Froxlor\Froxlor;
|
||||
use Froxlor\FileDir;
|
||||
use Froxlor\FroxlorLogger;
|
||||
use Froxlor\Http\Directory;
|
||||
@@ -36,14 +37,9 @@ use Froxlor\Http\Statistics;
|
||||
use Froxlor\Settings;
|
||||
use Froxlor\Validate\Validate;
|
||||
use Froxlor\System\Crypt;
|
||||
use Froxlor\Idna\IdnaWrapper;
|
||||
use PDO;
|
||||
|
||||
/**
|
||||
* @author Florian Lippert <flo@syscp.org> (2003-2009)
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
*
|
||||
* @todo ssl-redirect to non-standard port
|
||||
*/
|
||||
class Lighttpd extends HttpConfigBase
|
||||
{
|
||||
|
||||
@@ -81,7 +77,7 @@ class Lighttpd extends HttpConfigBase
|
||||
$ipv6 = '';
|
||||
}
|
||||
|
||||
$this->logger->logAction(FroxlorLogger::CRON_ACTION, LOG_INFO, 'lighttpd::createIpPort: creating ip/port settings for ' . $ip . ":" . $port);
|
||||
FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_INFO, 'lighttpd::createIpPort: creating ip/port settings for ' . $ip . ":" . $port);
|
||||
$vhost_filename = FileDir::makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/10_froxlor_ipandport_' . trim(str_replace(':', '.', $row_ipsandports['ip']), '.') . '.' . $row_ipsandports['port'] . '.conf');
|
||||
|
||||
if (!isset($this->lighttpd_data[$vhost_filename])) {
|
||||
@@ -126,13 +122,13 @@ class Lighttpd extends HttpConfigBase
|
||||
|
||||
if (!$is_redirect) {
|
||||
// protect lib/userdata.inc.php
|
||||
$this->lighttpd_data[$vhosts_filename] .= ' $HTTP["host"] =~ "' . rtrim(Froxlor::getInstallDir(), "/") . '/lib" {' . "\n";
|
||||
$this->lighttpd_data[$vhosts_filename] .= ' url.access-deny = ("userdata.inc.php")' . "\n";
|
||||
$this->lighttpd_data[$vhosts_filename] .= ' }' . "\n";
|
||||
$this->lighttpd_data[$vhost_filename] .= ' $HTTP["host"] =~ "' . rtrim(Froxlor::getInstallDir(), "/") . '/lib" {' . "\n";
|
||||
$this->lighttpd_data[$vhost_filename] .= ' url.access-deny = ("userdata.inc.php")' . "\n";
|
||||
$this->lighttpd_data[$vhost_filename] .= ' }' . "\n";
|
||||
// protect bin/
|
||||
$this->lighttpd_data[$vhosts_filename] .= ' $HTTP["host"] =~ "' . rtrim(Froxlor::getInstallDir(), "/") . '/bin" {' . "\n";
|
||||
$this->lighttpd_data[$vhosts_filename] .= ' url.access-deny = ("")' . "\n";
|
||||
$this->lighttpd_data[$vhosts_filename] .= ' }' . "\n";
|
||||
$this->lighttpd_data[$vhost_filename] .= ' $HTTP["host"] =~ "' . rtrim(Froxlor::getInstallDir(), "/") . '/bin" {' . "\n";
|
||||
$this->lighttpd_data[$vhost_filename] .= ' url.access-deny = ("")' . "\n";
|
||||
$this->lighttpd_data[$vhost_filename] .= ' }' . "\n";
|
||||
|
||||
/**
|
||||
* dirprotection, see #72
|
||||
@@ -222,7 +218,7 @@ class Lighttpd extends HttpConfigBase
|
||||
if (($row_ipsandports['ssl_cert_file'] == '' || !file_exists($row_ipsandports['ssl_cert_file'])) && (Settings::Get('system.le_froxlor_enabled') == '0' || $this->froxlorVhostHasLetsEncryptCert() == false)) {
|
||||
$row_ipsandports['ssl_cert_file'] = Settings::Get('system.ssl_cert_file');
|
||||
if (!file_exists($row_ipsandports['ssl_cert_file'])) {
|
||||
$this->logger->logAction(FroxlorLogger::CRON_ACTION, LOG_DEBUG, 'System certificate file "' . Settings::Get('system.ssl_cert_file') . '" does not seem to exist. Creating self-signed certificate...');
|
||||
FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_DEBUG, 'System certificate file "' . Settings::Get('system.ssl_cert_file') . '" does not seem to exist. Creating self-signed certificate...');
|
||||
Crypt::createSelfSignedCertificate();
|
||||
}
|
||||
}
|
||||
@@ -264,7 +260,7 @@ class Lighttpd extends HttpConfigBase
|
||||
if ($domain['ssl_cert_file'] != '') {
|
||||
// check for existence, #1485
|
||||
if (!file_exists($domain['ssl_cert_file'])) {
|
||||
$this->logger->logAction(FroxlorLogger::CRON_ACTION, LOG_ERR, $ip . ':' . $port . ' :: certificate file "' . $domain['ssl_cert_file'] . '" does not exist! Cannot create ssl-directives');
|
||||
FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_ERR, $ip . ':' . $port . ' :: certificate file "' . $domain['ssl_cert_file'] . '" does not exist! Cannot create ssl-directives');
|
||||
echo $ip . ':' . $port . ' :: certificate file "' . $domain['ssl_cert_file'] . '" does not exist! Cannot create SSL-directives' . "\n";
|
||||
} else {
|
||||
$this->lighttpd_data[$vhost_filename] .= 'ssl.engine = "enable"' . "\n";
|
||||
@@ -286,7 +282,7 @@ class Lighttpd extends HttpConfigBase
|
||||
if ($domain['ssl_ca_file'] != '') {
|
||||
// check for existence, #1485
|
||||
if (!file_exists($domain['ssl_ca_file'])) {
|
||||
$this->logger->logAction(FroxlorLogger::CRON_ACTION, LOG_ERR, $ip . ':' . $port . ' :: certificate CA file "' . $domain['ssl_ca_file'] . '" does not exist! Cannot create ssl-directives');
|
||||
FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_ERR, $ip . ':' . $port . ' :: certificate CA file "' . $domain['ssl_ca_file'] . '" does not exist! Cannot create ssl-directives');
|
||||
echo $ip . ':' . $port . ' :: certificate CA file "' . $domain['ssl_ca_file'] . '" does not exist! SSL-directives might not be working' . "\n";
|
||||
} else {
|
||||
$this->lighttpd_data[$vhost_filename] .= 'ssl.ca-file = "' . FileDir::makeCorrectFile($domain['ssl_ca_file']) . '"' . "\n";
|
||||
@@ -571,21 +567,19 @@ class Lighttpd extends HttpConfigBase
|
||||
$this->deactivated = true;
|
||||
} else {
|
||||
if ($ssl === false && $domain['ssl_redirect'] == '1') {
|
||||
$redirect_domain = $this->idnaConvert->encode('https://' . $domain['domain']);
|
||||
$webroot_text .= ' url.redirect = (' . "\n";
|
||||
$webroot_text .= "\t" . '"^/(.*)" => "' . $redirect_domain . '/$1",' . "\n";
|
||||
$webroot_text .= "\t" . '"" => "' . $redirect_domain . '",' . "\n";
|
||||
$webroot_text .= "\t" . '"/" => "' . $redirect_domain . '"' . "\n";
|
||||
$webroot_text .= ' )' . "\n";
|
||||
$redirect_domain = (new IdnaWrapper)->encode('https://' . $domain['domain']);
|
||||
} elseif (preg_match("#^https?://#i", $domain['documentroot'])) {
|
||||
$redirect_domain = $this->idnaConvert->encode($domain['documentroot']);
|
||||
$webroot_text .= ' url.redirect = (' . "\n";
|
||||
$webroot_text .= "\t" . '"^/(.*)" => "' . $redirect_domain . '/$1",' . "\n";
|
||||
$webroot_text .= "\t" . '"" => "' . $redirect_domain . '",' . "\n";
|
||||
$webroot_text .= "\t" . '"/" => "' . $redirect_domain . '"' . "\n";
|
||||
$webroot_text .= ' )' . "\n";
|
||||
$redirect_domain = (new IdnaWrapper)->encode($domain['documentroot']);
|
||||
} else {
|
||||
$webroot_text .= ' server.document-root = "' . FileDir::makeCorrectDir($domain['documentroot']) . "\"\n";
|
||||
$redirect_domain = '';
|
||||
}
|
||||
if (!empty($redirect_domain)) {
|
||||
$webroot_text .= ' url.redirect = (' . "\n";
|
||||
$webroot_text .= "\t" . '"^/(.*)" => "' . $redirect_domain . '/$1",' . "\n";
|
||||
$webroot_text .= "\t" . '"" => "' . $redirect_domain . '",' . "\n";
|
||||
$webroot_text .= "\t" . '"/" => "' . $redirect_domain . '"' . "\n";
|
||||
$webroot_text .= ' )' . "\n";
|
||||
}
|
||||
$this->deactivated = false;
|
||||
}
|
||||
@@ -765,7 +759,7 @@ class Lighttpd extends HttpConfigBase
|
||||
if (!file_exists($domain['ssl_cert_file'])) {
|
||||
// explicitly disable ssl for this vhost
|
||||
$domain['ssl_cert_file'] = "";
|
||||
$this->logger->logAction(FroxlorLogger::CRON_ACTION, LOG_DEBUG, 'System certificate file "' . Settings::Get('system.ssl_cert_file') . '" does not seem to exist. Disabling SSL-vhost for "' . $domain['domain'] . '"');
|
||||
FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_DEBUG, 'System certificate file "' . Settings::Get('system.ssl_cert_file') . '" does not seem to exist. Disabling SSL-vhost for "' . $domain['domain'] . '"');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -923,7 +917,7 @@ class Lighttpd extends HttpConfigBase
|
||||
|
||||
public function writeConfigs()
|
||||
{
|
||||
$this->logger->logAction(FroxlorLogger::CRON_ACTION, LOG_INFO, "lighttpd::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_vhost'));
|
||||
FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_INFO, "lighttpd::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_vhost'));
|
||||
|
||||
$vhostDir = new Directory(Settings::Get('system.apacheconf_vhost'));
|
||||
if (!$vhostDir->isConfigDir()) {
|
||||
@@ -950,14 +944,12 @@ class Lighttpd extends HttpConfigBase
|
||||
fclose($vhosts_file_handler);
|
||||
} else {
|
||||
if (!file_exists(Settings::Get('system.apacheconf_vhost'))) {
|
||||
$this->logger->logAction(FroxlorLogger::CRON_ACTION, LOG_NOTICE, 'lighttpd::writeConfigs: mkdir ' . escapeshellarg(FileDir::makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
|
||||
FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_NOTICE, 'lighttpd::writeConfigs: mkdir ' . escapeshellarg(FileDir::makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
|
||||
FileDir::safe_exec('mkdir ' . escapeshellarg(FileDir::makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
|
||||
}
|
||||
|
||||
// Write a single file for every vhost
|
||||
foreach ($this->lighttpd_data as $vhosts_filename => $vhosts_file) {
|
||||
$this->known_filenames[] = basename($vhosts_filename);
|
||||
|
||||
// Apply header
|
||||
$vhosts_file = '# ' . basename($vhosts_filename) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n" . "\n" . $vhosts_file;
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ use Froxlor\Cron\Http\Php\PhpInterface;
|
||||
use Froxlor\Customer\Customer;
|
||||
use Froxlor\Database\Database;
|
||||
use Froxlor\Domain\Domain;
|
||||
use Froxlor\Froxlor;
|
||||
use Froxlor\FileDir;
|
||||
use Froxlor\FroxlorLogger;
|
||||
use Froxlor\Http\Directory;
|
||||
@@ -50,8 +51,7 @@ class Nginx extends HttpConfigBase
|
||||
protected $known_htpasswdsfilenames = [];
|
||||
protected $mod_accesslog_loaded = '0';
|
||||
protected $vhost_root_autoindex = false;
|
||||
protected $known_vhostfilenames = [];
|
||||
private $nginx_server = [];
|
||||
|
||||
/**
|
||||
* indicator whether a customer is deactivated or not
|
||||
* if yes, only the webroot will be generated
|
||||
@@ -60,11 +60,6 @@ class Nginx extends HttpConfigBase
|
||||
*/
|
||||
private $deactivated = false;
|
||||
|
||||
public function __construct($nginx_server = [])
|
||||
{
|
||||
$this->nginx_server = $nginx_server;
|
||||
}
|
||||
|
||||
public function createVirtualHosts()
|
||||
{
|
||||
return;
|
||||
@@ -220,14 +215,14 @@ class Nginx extends HttpConfigBase
|
||||
$this->nginx_data[$vhost_filename] .= "\t" . '}' . "\n";
|
||||
|
||||
// protect lib/userdata.inc.php
|
||||
$this->nginx_data[$vhosts_filename] .= "\t" . 'location = ' . rtrim(Froxlor::getInstallDir(), "/") . '/lib/userdata.inc.php {' . "\n";
|
||||
$this->nginx_data[$vhosts_filename] .= "\t" . ' deny all;' . "\n";
|
||||
$this->nginx_data[$vhosts_filename] .= "\t" . '}' . "\n";
|
||||
$this->nginx_data[$vhost_filename] .= "\t" . 'location = ' . rtrim(Froxlor::getInstallDir(), "/") . '/lib/userdata.inc.php {' . "\n";
|
||||
$this->nginx_data[$vhost_filename] .= "\t" . ' deny all;' . "\n";
|
||||
$this->nginx_data[$vhost_filename] .= "\t" . '}' . "\n";
|
||||
|
||||
// protect bin/
|
||||
$this->nginx_data[$vhosts_filename] .= "\t" . 'location = ' . rtrim(Froxlor::getInstallDir(), "/") . '/bin {' . "\n";
|
||||
$this->nginx_data[$vhosts_filename] .= "\t" . ' deny all;' . "\n";
|
||||
$this->nginx_data[$vhosts_filename] .= "\t" . '}' . "\n";
|
||||
$this->nginx_data[$vhost_filename] .= "\t" . 'location = ' . rtrim(Froxlor::getInstallDir(), "/") . '/bin {' . "\n";
|
||||
$this->nginx_data[$vhost_filename] .= "\t" . ' deny all;' . "\n";
|
||||
$this->nginx_data[$vhost_filename] .= "\t" . '}' . "\n";
|
||||
}
|
||||
|
||||
if ($row_ipsandports['specialsettings'] != '' && ($row_ipsandports['ssl'] == '0' || ($row_ipsandports['ssl'] == '1' && Settings::Get('system.use_ssl') == '1' && $row_ipsandports['include_specialsettings'] == '1'))) {
|
||||
@@ -1252,8 +1247,6 @@ class Nginx extends HttpConfigBase
|
||||
|
||||
// Write a single file for every vhost
|
||||
foreach ($this->nginx_data as $vhosts_filename => $vhosts_file) {
|
||||
$this->known_filenames[] = basename($vhosts_filename);
|
||||
|
||||
// Apply header
|
||||
$vhosts_file = '# ' . basename($vhosts_filename) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n" . "\n" . $vhosts_file;
|
||||
|
||||
|
||||
@@ -46,11 +46,11 @@ class PhpInterface
|
||||
private $interface = null;
|
||||
|
||||
/**
|
||||
* Admin-User data array
|
||||
* PHP-Config data array
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $admin_cache = [];
|
||||
private $php_configs_cache = [];
|
||||
|
||||
/**
|
||||
* main constructor
|
||||
@@ -93,10 +93,8 @@ class PhpInterface
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPhpConfig($php_config_id)
|
||||
public function getPhpConfig(int $php_config_id)
|
||||
{
|
||||
$php_config_id = intval($php_config_id);
|
||||
|
||||
// If domain has no config, we will use the default one.
|
||||
if ($php_config_id == 0) {
|
||||
$php_config_id = 1;
|
||||
@@ -104,24 +102,26 @@ class PhpInterface
|
||||
|
||||
if (!isset($this->php_configs_cache[$php_config_id])) {
|
||||
$stmt = Database::prepare("
|
||||
SELECT * FROM `" . TABLE_PANEL_PHPCONFIGS . "` WHERE `id` = :id");
|
||||
$this->_php_configs_cache[$php_config_id] = Database::pexecute_first($stmt, [
|
||||
SELECT * FROM `" . TABLE_PANEL_PHPCONFIGS . "` WHERE `id` = :id
|
||||
");
|
||||
$this->php_configs_cache[$php_config_id] = Database::pexecute_first($stmt, [
|
||||
'id' => $php_config_id
|
||||
]);
|
||||
if ((int)Settings::Get('phpfpm.enabled') == 1) {
|
||||
$stmt = Database::prepare("
|
||||
SELECT * FROM `" . TABLE_PANEL_FPMDAEMONS . "` WHERE `id` = :id");
|
||||
$this->_php_configs_cache[$php_config_id]['fpm_settings'] = Database::pexecute_first($stmt, [
|
||||
'id' => $this->_php_configs_cache[$php_config_id]['fpmsettingid']
|
||||
SELECT * FROM `" . TABLE_PANEL_FPMDAEMONS . "` WHERE `id` = :id
|
||||
");
|
||||
$this->php_configs_cache[$php_config_id]['fpm_settings'] = Database::pexecute_first($stmt, [
|
||||
'id' => $this->php_configs_cache[$php_config_id]['fpmsettingid']
|
||||
]);
|
||||
// override fpm daemon settings if set in php-config
|
||||
if ($this->_php_configs_cache[$php_config_id]['override_fpmconfig'] == 1) {
|
||||
$this->_php_configs_cache[$php_config_id]['fpm_settings']['limit_extensions'] = $this->_php_configs_cache[$php_config_id]['limit_extensions'];
|
||||
$this->_php_configs_cache[$php_config_id]['fpm_settings']['idle_timeout'] = $this->_php_configs_cache[$php_config_id]['idle_timeout'];
|
||||
if ($this->php_configs_cache[$php_config_id]['override_fpmconfig'] == 1) {
|
||||
$this->php_configs_cache[$php_config_id]['fpm_settings']['limit_extensions'] = $this->php_configs_cache[$php_config_id]['limit_extensions'];
|
||||
$this->php_configs_cache[$php_config_id]['fpm_settings']['idle_timeout'] = $this->php_configs_cache[$php_config_id]['idle_timeout'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_php_configs_cache[$php_config_id];
|
||||
return $this->php_configs_cache[$php_config_id];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,6 +127,9 @@ class Database
|
||||
{
|
||||
global $userinfo, $theme, $linker;
|
||||
|
||||
$sql = [];
|
||||
$sql_root = [];
|
||||
|
||||
// include userdata.inc.php
|
||||
require Froxlor::getInstallDir() . "/lib/userdata.inc.php";
|
||||
|
||||
|
||||
@@ -26,12 +26,10 @@
|
||||
namespace Froxlor;
|
||||
|
||||
use Exception;
|
||||
use Froxlor\Customer\Customer;
|
||||
use Froxlor\Database\Database;
|
||||
use PDO;
|
||||
use RecursiveCallbackFilterIterator;
|
||||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
use Froxlor\Customer\Customer;
|
||||
use Froxlor\Database\Database;
|
||||
|
||||
class FileDir
|
||||
{
|
||||
@@ -550,12 +548,11 @@ class FileDir
|
||||
/**
|
||||
* set the immutable flag for a file
|
||||
*
|
||||
* @param string $filename
|
||||
* the file to set the flag for
|
||||
* @param string $filename the file to set the flag for
|
||||
*
|
||||
* @return boolean
|
||||
* @return void
|
||||
*/
|
||||
public static function setImmutable($filename = null)
|
||||
public static function setImmutable(string $filename)
|
||||
{
|
||||
FileDir::safe_exec(self::getImmutableFunction(false) . escapeshellarg($filename));
|
||||
}
|
||||
@@ -564,12 +561,11 @@ class FileDir
|
||||
* internal function to check whether
|
||||
* to use chattr (Linux) or chflags (FreeBSD)
|
||||
*
|
||||
* @param boolean $remove
|
||||
* whether to use +i|schg (false) or -i|noschg (true)
|
||||
* @param bool $remove whether to use +i|schg (false) or -i|noschg (true)
|
||||
*
|
||||
* @return string functionname + parameter (not the file)
|
||||
*/
|
||||
private static function getImmutableFunction($remove = false)
|
||||
private static function getImmutableFunction(bool $remove = false)
|
||||
{
|
||||
if (self::isFreeBSD()) {
|
||||
// FreeBSD style
|
||||
@@ -585,12 +581,11 @@ class FileDir
|
||||
* or BSD-based (NetBSD, OpenBSD, etc.
|
||||
* if exact = false [default])
|
||||
*
|
||||
* @param boolean $exact
|
||||
* whether to check explicitly for FreeBSD or *BSD
|
||||
* @param bool $exact whether to check explicitly for FreeBSD or *BSD
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public static function isFreeBSD($exact = false)
|
||||
public static function isFreeBSD(bool $exact = false)
|
||||
{
|
||||
if (($exact && PHP_OS == 'FreeBSD') || (!$exact && stristr(PHP_OS, 'BSD'))) {
|
||||
return true;
|
||||
@@ -601,16 +596,19 @@ class FileDir
|
||||
/**
|
||||
* removes the immutable flag for a file
|
||||
*
|
||||
* @param string $filename
|
||||
* the file to set the flag for
|
||||
* @param string $filename the file to set the flag for
|
||||
*
|
||||
* @return boolean
|
||||
* @return void
|
||||
*/
|
||||
public static function removeImmutable($filename = null)
|
||||
public static function removeImmutable(string $filename)
|
||||
{
|
||||
FileDir::safe_exec(self::getImmutableFunction(true) . escapeshellarg($filename));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array|false
|
||||
*/
|
||||
public static function getFilesystemQuota()
|
||||
{
|
||||
// enabled at all?
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
namespace Froxlor\Install;
|
||||
|
||||
use Exception;
|
||||
use ZipArchive;
|
||||
use Froxlor\Froxlor;
|
||||
use Froxlor\Settings;
|
||||
use Froxlor\Http\HttpClient;
|
||||
|
||||
@@ -31,6 +31,9 @@ use Froxlor\Settings;
|
||||
|
||||
class Update
|
||||
{
|
||||
private static $update_tasks = [];
|
||||
|
||||
private static $task_counter = 0;
|
||||
|
||||
/**
|
||||
* Function showUpdateStep
|
||||
@@ -42,20 +45,18 @@ class Update
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function showUpdateStep($task = null, $needs_status = true)
|
||||
public static function showUpdateStep(string $task, bool $needs_status = true)
|
||||
{
|
||||
global $update_tasks, $task_counter;
|
||||
|
||||
set_time_limit(30);
|
||||
|
||||
// output
|
||||
$update_tasks[$task_counter] = ['title' => $task, 'result' => 0];
|
||||
self::$update_tasks[self::$task_counter] = ['title' => $task, 'result' => 0];
|
||||
|
||||
if (!$needs_status) {
|
||||
$task_counter++;
|
||||
self::$task_counter++;
|
||||
}
|
||||
|
||||
FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::ADM_ACTION, LOG_WARNING, $task);
|
||||
FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::ADM_ACTION, \LOG_WARNING, $task);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,35 +68,33 @@ class Update
|
||||
* @param string $message
|
||||
* @param string $additional_info
|
||||
*
|
||||
* @return string formatted output and log-entry
|
||||
* @return void
|
||||
*/
|
||||
public static function lastStepStatus(int $status = -1, string $message = '', string $additional_info = '')
|
||||
{
|
||||
global $update_tasks, $task_counter;
|
||||
|
||||
$update_tasks[$task_counter]['result_txt'] = $message ?? 'OK';
|
||||
$update_tasks[$task_counter]['result_desc'] = $additional_info ?? '';
|
||||
self::$update_tasks[self::$task_counter]['result_txt'] = $message ?? 'OK';
|
||||
self::$update_tasks[self::$task_counter]['result_desc'] = $additional_info ?? '';
|
||||
|
||||
switch ($status) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
$update_tasks[$task_counter]['result'] = 2;
|
||||
self::$update_tasks[self::$task_counter]['result'] = 2;
|
||||
break;
|
||||
case 2:
|
||||
$update_tasks[$task_counter]['result'] = 1;
|
||||
self::$update_tasks[self::$task_counter]['result'] = 1;
|
||||
break;
|
||||
default:
|
||||
$update_tasks[$task_counter]['result'] = -1;
|
||||
self::$update_tasks[self::$task_counter]['result'] = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
$task_counter++;
|
||||
self::$task_counter++;
|
||||
|
||||
if ($status == -1 || $status == 2) {
|
||||
FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::ADM_ACTION, LOG_WARNING, 'Attention - last update task failed!!!');
|
||||
FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::ADM_ACTION, \LOG_WARNING, 'Attention - last update task failed!!!');
|
||||
} elseif ($status == 0 || $status == 1) {
|
||||
FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::ADM_ACTION, LOG_WARNING, 'Success');
|
||||
FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::ADM_ACTION, \LOG_WARNING, 'Success');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,4 +126,14 @@ class Update
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getUpdateTasks(): array
|
||||
{
|
||||
return self::$update_tasks;
|
||||
}
|
||||
|
||||
public static function getTaskCounter(): int
|
||||
{
|
||||
return self::$task_counter;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,6 @@ class Listing
|
||||
{
|
||||
return [
|
||||
'title' => $tabellisting['title'],
|
||||
'icon' => $tabellisting['icon'],
|
||||
'description' => $tabellisting['description'] ?? null,
|
||||
'icon' => $tabellisting['icon'] ?? null,
|
||||
'table' => [
|
||||
|
||||
@@ -46,23 +46,19 @@ class Validate
|
||||
const REGEX_YYYY_MM_DD = '/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/';
|
||||
|
||||
/**
|
||||
* Validates the given string by matching against the pattern, prints an error on failure and exits
|
||||
* Validates the given string by matching against the pattern, prints an error on failure and exits.
|
||||
* If the default pattern is used and the string does not match, we try to replace the 'bad' values and log the action.
|
||||
*
|
||||
* @param string $str
|
||||
* the string to be tested (user input)
|
||||
* @param
|
||||
* string the $fieldname to be used in error messages
|
||||
* @param string $pattern
|
||||
* the regular expression to be used for testing
|
||||
* @param
|
||||
* string language id for the error
|
||||
* @return string the clean string
|
||||
*
|
||||
* If the default pattern is used and the string does not match, we try to replace the
|
||||
* 'bad' values and log the action.
|
||||
* @param string $str the string to be tested (user input)
|
||||
* @param string $fieldname to be used in error messages
|
||||
* @param string $pattern the regular expression to be used for testing
|
||||
* @param string $language id for the error
|
||||
* @param string|array $emptydefault fallback value
|
||||
* @param bool $throw_exception whether to display error or throw an exception, default false
|
||||
*
|
||||
* @return string|void the clean string or error
|
||||
*/
|
||||
public static function validate($str, $fieldname, $pattern = '', $lng = '', $emptydefault = [], $throw_exception = false)
|
||||
public static function validate($str, string $fieldname, string $pattern = '', string $lng = '', $emptydefault = [], bool $throw_exception = false)
|
||||
{
|
||||
if (!is_array($emptydefault)) {
|
||||
$emptydefault_array = [
|
||||
@@ -122,9 +118,9 @@ class Validate
|
||||
* @param bool $throw_exception
|
||||
* whether to throw an exception on failure
|
||||
*
|
||||
* @return string|bool ip address on success, false on failure
|
||||
* @return string|bool|void ip address on success, false on failure (or nothing if error is displayed)
|
||||
*/
|
||||
public static function validate_ip2($ip, $return_bool = false, $lng = 'invalidip', $allow_localhost = false, $allow_priv = false, $allow_cidr = false, $cidr_as_netmask = false, $throw_exception = false)
|
||||
public static function validate_ip2($ip, bool $return_bool = false, string $lng = 'invalidip', bool $allow_localhost = false, bool $allow_priv = false, bool $allow_cidr = false, bool $cidr_as_netmask = false, bool $throw_exception = false)
|
||||
{
|
||||
$cidr = "";
|
||||
if ($allow_cidr) {
|
||||
@@ -136,15 +132,17 @@ class Validate
|
||||
$cidr_range_max = 128;
|
||||
}
|
||||
if (strlen($ip_cidr[1]) <= 3 && in_array((int)$ip_cidr[1], array_values(range(1, $cidr_range_max)), true) === false) {
|
||||
if ($return_bool) {
|
||||
return false;
|
||||
}
|
||||
Response::standardError($lng, $ip, $throw_exception);
|
||||
}
|
||||
if ($cidr_as_netmask && IPTools::is_ipv6($ip_cidr[0])) {
|
||||
// MySQL does not handle CIDR of IPv6 addresses, return error
|
||||
if ($return_bool) {
|
||||
return false;
|
||||
} else {
|
||||
Response::standardError($lng, $ip, $throw_exception);
|
||||
}
|
||||
Response::standardError($lng, $ip, $throw_exception);
|
||||
}
|
||||
$ip = $ip_cidr[0];
|
||||
if ($cidr_as_netmask && strlen($ip_cidr[1]) <= 3) {
|
||||
@@ -157,9 +155,8 @@ class Validate
|
||||
} elseif (strpos($ip, "/") !== false) {
|
||||
if ($return_bool) {
|
||||
return false;
|
||||
} else {
|
||||
Response::standardError($lng, $ip, $throw_exception);
|
||||
}
|
||||
Response::standardError($lng, $ip, $throw_exception);
|
||||
}
|
||||
|
||||
$filter_lan = $allow_priv ? FILTER_FLAG_NO_RES_RANGE : (FILTER_FLAG_NO_RES_RANGE | FILTER_FLAG_NO_PRIV_RANGE);
|
||||
@@ -175,9 +172,8 @@ class Validate
|
||||
|
||||
if ($return_bool) {
|
||||
return false;
|
||||
} else {
|
||||
Response::standardError($lng, $ip, $throw_exception);
|
||||
}
|
||||
Response::standardError($lng, $ip, $throw_exception);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user