merge branch '0.11-dev' of https://github.com/Froxlor/Froxlor into 0.11-dev

This commit is contained in:
envoyr
2022-04-20 17:01:33 +02:00
15 changed files with 159 additions and 94 deletions

View File

@@ -233,7 +233,7 @@ return array(
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
'advanced_mode' => true 'advanced_mode' => true
), ),
'system_disable_le_selfcheck' => array( 'system_le_domain_dnscheck' => array(
'label' => $lng['serversettings']['le_domain_dnscheck'], 'label' => $lng['serversettings']['le_domain_dnscheck'],
'settinggroup' => 'system', 'settinggroup' => 'system',
'varname' => 'le_domain_dnscheck', 'varname' => 'le_domain_dnscheck',

View File

@@ -29,6 +29,7 @@ define('UPDATE_URI', "https://version.froxlor.org/Froxlor/api/" . \Froxlor\Froxl
define('RELEASE_URI', "https://autoupdate.froxlor.org/froxlor-{version}.zip"); define('RELEASE_URI', "https://autoupdate.froxlor.org/froxlor-{version}.zip");
define('CHECKSUM_URI', "https://autoupdate.froxlor.org/froxlor-{version}.zip.sha256"); define('CHECKSUM_URI', "https://autoupdate.froxlor.org/froxlor-{version}.zip.sha256");
if ($page != 'error') {
// check for archive-stuff // check for archive-stuff
if (!extension_loaded('zip')) { if (!extension_loaded('zip')) {
\Froxlor\UI\Response::redirectTo($filename, array( \Froxlor\UI\Response::redirectTo($filename, array(
@@ -45,6 +46,15 @@ if (version_compare("7.4.0", PHP_VERSION, ">=")) {
)); ));
} }
// check for webupdate to be enabled
if (\Froxlor\Settings::Config('enable_webupdate') != true) {
\Froxlor\UI\Response::redirectTo($filename, array(
'page' => 'error',
'errno' => 11
));
}
}
// display initial version check // display initial version check
if ($page == 'overview') { if ($page == 'overview') {
@@ -281,5 +291,6 @@ elseif ($page == 'error') {
// 8 = could not extract archive // 8 = could not extract archive
// 9 = checksum mismatch // 9 = checksum mismatch
// 10 = <php-7.4 // 10 = <php-7.4
// 11 = enable_webupdate = false
\Froxlor\UI\Response::standard_error('autoupdate_' . $errno); \Froxlor\UI\Response::standard_error('autoupdate_' . $errno);
} }

View File

@@ -23,7 +23,7 @@ require __DIR__ . '/lib/tables.inc.php';
// Return response // Return response
try { try {
echo (new Api)->handle(@file_get_contents('php://input')); echo (new Api)->formatMiddleware(@file_get_contents('php://input'))->handle();
} catch (Exception $e) { } catch (Exception $e) {
echo \Froxlor\Api\Response::jsonErrorResponse($e->getMessage(), $e->getCode()); echo \Froxlor\Api\Response::jsonErrorResponse($e->getMessage(), $e->getCode());
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
namespace Froxlor\Api; namespace Froxlor\Api;
use Exception; use Exception;
@@ -23,6 +24,8 @@ class Api
{ {
protected array $headers; protected array $headers;
protected $request = null;
/** /**
* Api constructor. * Api constructor.
* *
@@ -42,14 +45,34 @@ class Api
} }
} }
/**
* @param mixed $request
*
* @return Api
*/
public function formatMiddleware($request): Api
{
// check auf RESTful api call
$this->request = $request;
$uri = parse_url($_SERVER["REQUEST_URI"], PHP_URL_QUERY);
// map /module/command to internal request array if match
if (!empty($uri) && preg_match("/^\/([a-z]+)\/([a-z]+)\/?/", $uri, $matches)) {
$request = [];
$request['command'] = ucfirst($matches[1]) . '.' . $matches[2];
$request['params'] = !empty($this->request) ? json_decode($this->request, true) : null;
$this->request = json_encode($request);
}
return $this;
}
/** /**
* Handle incoming api request to our backend. * Handle incoming api request to our backend.
* *
* @param mixed $request
* @throws Exception * @throws Exception
*/ */
public function handle($request) public function handle()
{ {
$request = $this->request;
// validate content // validate content
$request = \Froxlor\Api\FroxlorRPC::validateRequest($request); $request = \Froxlor\Api\FroxlorRPC::validateRequest($request);
$request = (new AntiXSS())->xss_clean( $request = (new AntiXSS())->xss_clean(

View File

@@ -760,6 +760,7 @@ class Lighttpd extends HttpConfigBase
'customerid' => $domain['customerid'] 'customerid' => $domain['customerid']
)); ));
$diroption_text = '';
while ($row_htpasswds = $result_stmt->fetch(\PDO::FETCH_ASSOC)) { while ($row_htpasswds = $result_stmt->fetch(\PDO::FETCH_ASSOC)) {
if ($this->auth_backend_loaded[$domain['ipandport']] != 'yes' && $this->auth_backend_loaded[$domain['ssl_ipandport']] != 'yes') { if ($this->auth_backend_loaded[$domain['ipandport']] != 'yes' && $this->auth_backend_loaded[$domain['ssl_ipandport']] != 'yes') {
$filename = $domain['customerid'] . '.htpasswd'; $filename = $domain['customerid'] . '.htpasswd';
@@ -836,6 +837,7 @@ class Lighttpd extends HttpConfigBase
} }
} }
$servernames_text = '';
for ($i = 0; $i < sizeof($server_string); $i ++) { for ($i = 0; $i < sizeof($server_string); $i ++) {
$data = $server_string[$i]; $data = $server_string[$i];

View File

@@ -324,8 +324,8 @@ class TasksCron extends \Froxlor\Cron\FroxlorCron
if (file_exists($logsdir) && $logsdir != '/' && $logsdir != \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.logfiles_directory')) && substr($logsdir, 0, strlen(Settings::Get('system.logfiles_directory'))) == Settings::Get('system.logfiles_directory')) { if (file_exists($logsdir) && $logsdir != '/' && $logsdir != \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.logfiles_directory')) && substr($logsdir, 0, strlen(Settings::Get('system.logfiles_directory'))) == Settings::Get('system.logfiles_directory')) {
// build up wildcard for webX-{access,error}.log{*} // build up wildcard for webX-{access,error}.log{*}
$logfiles .= '-*'; $logsdir .= '-*';
\Froxlor\FileDir::safe_exec('rm -f ' . escapeshellarg($logfiles)); \Froxlor\FileDir::safe_exec('rm -f ' . escapeshellarg($logsdir));
} }
} }
} }

View File

@@ -496,7 +496,7 @@ class FileDir
}; };
// create RecursiveIteratorIterator // create RecursiveIteratorIterator
$its = new \RecursiveIteratorIterator(new \RecursiveCallbackFilterIterator(new System\IgnorantRecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), $filter)); $its = new \RecursiveIteratorIterator(new \RecursiveCallbackFilterIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), $filter));
// we can limit the recursion-depth, but will it be helpful or // we can limit the recursion-depth, but will it be helpful or
// will people start asking "why do I only see 2 subdirectories, i want to use /a/b/c" // will people start asking "why do I only see 2 subdirectories, i want to use /a/b/c"
// let's keep this in mind and see whether it will be useful // let's keep this in mind and see whether it will be useful

View File

@@ -1,4 +1,5 @@
<?php <?php
namespace Froxlor; namespace Froxlor;
use Froxlor\Database\Database; use Froxlor\Database\Database;
@@ -43,6 +44,13 @@ class Settings
*/ */
private static $data = null; private static $data = null;
/**
* local config overrides
*
* @var array
*/
private static $conf = null;
/** /**
* changed and unsaved settings data * changed and unsaved settings data
* *
@@ -65,6 +73,7 @@ class Settings
{ {
if (empty(self::$data)) { if (empty(self::$data)) {
self::readSettings(); self::readSettings();
self::readConfig();
self::$updatedata = array(); self::$updatedata = array();
// prepare statement // prepare statement
@@ -92,6 +101,24 @@ class Settings
return true; return true;
} }
/**
* Read in all config overrides from
* config/config.inc.php
*/
private static function readConfig()
{
// set defaults
self::$conf = [
'enable_webupdate' => false
];
$configfile = Froxlor::getInstallDir() . '/lib/config.inc.php';
if (@file_exists($configfile) && is_readable($configfile)) {
self::$conf = include $configfile;
}
return true;
}
/** /**
* update a value in the database * update a value in the database
* *
@@ -306,4 +333,19 @@ class Settings
} }
} }
} }
/**
* get value from config by identifier
*/
public static function Config(string $config)
{
self::init();
$sstr = explode(".", $config);
$result = self::$conf;
foreach ($sstr as $key) {
$result = $result[$key] ?? null;
if (empty($result)) break;
}
return $result;
}
} }

View File

@@ -1,21 +0,0 @@
<?php
namespace Froxlor\System;
/**
* If you use RecursiveDirectoryIterator with RecursiveIteratorIterator and run
* into UnexpectedValueException you may use this little hack to ignore those
* directories, such as lost+found on linux.
* (User "antennen" @ http://php.net/manual/en/class.recursivedirectoryiterator.php#101654)
*/
class IgnorantRecursiveDirectoryIterator extends \RecursiveDirectoryIterator
{
public function getChildren()
{
try {
return new IgnorantRecursiveDirectoryIterator($this->getPathname());
} catch (\UnexpectedValueException $e) {
return new \RecursiveArrayIterator(array());
}
}
}

8
lib/config.inc.php Normal file
View File

@@ -0,0 +1,8 @@
<?php
/**
* change the options below to either true or false
*/
return [
'enable_webupdate' => false
];

View File

@@ -119,7 +119,6 @@ return array(
'image' => 'icons/domain_add.png', 'image' => 'icons/domain_add.png',
'fields' => array( 'fields' => array(
'documentroot' => array( 'documentroot' => array(
'visible' => $userinfo['change_serversettings'] == '1',
'label' => 'DocumentRoot', 'label' => 'DocumentRoot',
'desc' => $lng['panel']['emptyfordefault'], 'desc' => $lng['panel']['emptyfordefault'],
'type' => 'text' 'type' => 'text'

View File

@@ -129,7 +129,6 @@ return array(
'image' => 'icons/domain_edit.png', 'image' => 'icons/domain_edit.png',
'fields' => array( 'fields' => array(
'documentroot' => array( 'documentroot' => array(
'visible' => $userinfo['change_serversettings'] == '1',
'label' => 'DocumentRoot', 'label' => 'DocumentRoot',
'desc' => $lng['panel']['emptyfordefault'], 'desc' => $lng['panel']['emptyfordefault'],
'type' => 'text', 'type' => 'text',

View File

@@ -228,7 +228,7 @@ return array(
'url' => 'admin_autoupdate.php?page=overview', 'url' => 'admin_autoupdate.php?page=overview',
'label' => $lng['admin']['autoupdate'], 'label' => $lng['admin']['autoupdate'],
'required_resources' => 'change_serversettings', 'required_resources' => 'change_serversettings',
'show_element' => extension_loaded('zip') 'show_element' => extension_loaded('zip') && \Froxlor\Settings::Config('enable_webupdate')
), ),
array( array(
'url' => 'admin_settings.php?page=wipecleartextmailpws', 'url' => 'admin_settings.php?page=wipecleartextmailpws',

View File

@@ -898,7 +898,7 @@ $lng['serversettings']['session_allow_multiple_login']['description'] = 'If acti
$lng['serversettings']['panel_allow_domain_change_admin']['title'] = 'Allow moving domains between admins'; $lng['serversettings']['panel_allow_domain_change_admin']['title'] = 'Allow moving domains between admins';
$lng['serversettings']['panel_allow_domain_change_admin']['description'] = 'If activated you can change the admin of a domain at domainsettings.<br /><b>Attention:</b> If a customer isn\'t assigned to the same admin as the domain, the admin can see every other domain of that customer!'; $lng['serversettings']['panel_allow_domain_change_admin']['description'] = 'If activated you can change the admin of a domain at domainsettings.<br /><b>Attention:</b> If a customer isn\'t assigned to the same admin as the domain, the admin can see every other domain of that customer!';
$lng['serversettings']['panel_allow_domain_change_customer']['title'] = 'Allow moving domains between customers'; $lng['serversettings']['panel_allow_domain_change_customer']['title'] = 'Allow moving domains between customers';
$lng['serversettings']['panel_allow_domain_change_customer']['description'] = 'If activated you can change the customer of a domain at domainsettings.<br /><b>Attention:</b> Froxlor won\'t change any paths. This could render a domain unusable!'; $lng['serversettings']['panel_allow_domain_change_customer']['description'] = 'If activated you can change the customer of a domain at domainsettings.<br /><b>Attention:</b> Froxlor changes the documentroot to the new customer\'s default homedir (+ domain-folder if activated)';
$lng['domains']['associated_with_domain'] = 'Associated'; $lng['domains']['associated_with_domain'] = 'Associated';
$lng['domains']['aliasdomains'] = 'Alias domains'; $lng['domains']['aliasdomains'] = 'Alias domains';
$lng['error']['ipportdoesntexist'] = 'The ip/port combination you have chosen doesn\'t exist.'; $lng['error']['ipportdoesntexist'] = 'The ip/port combination you have chosen doesn\'t exist.';
@@ -1878,6 +1878,7 @@ $lng['error']['autoupdate_7'] = 'The downloaded archive could not be found :(';
$lng['error']['autoupdate_8'] = 'The archive could not be extracted :('; $lng['error']['autoupdate_8'] = 'The archive could not be extracted :(';
$lng['error']['autoupdate_9'] = 'The downloaded file did not pass the integrity check. Please try to update again.'; $lng['error']['autoupdate_9'] = 'The downloaded file did not pass the integrity check. Please try to update again.';
$lng['error']['autoupdate_10'] = 'Minimum supported version of PHP is 7.4.0'; $lng['error']['autoupdate_10'] = 'Minimum supported version of PHP is 7.4.0';
$lng['error']['autoupdate_11'] = 'Webupdate is disabled';
$lng['admin']['server_php'] = 'PHP'; $lng['admin']['server_php'] = 'PHP';
$lng['domains']['termination_date'] = 'Date of termination'; $lng['domains']['termination_date'] = 'Date of termination';

View File

@@ -892,7 +892,7 @@ $lng['serversettings']['session_allow_multiple_login']['description'] = 'Wenn di
$lng['serversettings']['panel_allow_domain_change_admin']['title'] = 'Erlaube Verschieben von Domains unter Admins'; $lng['serversettings']['panel_allow_domain_change_admin']['title'] = 'Erlaube Verschieben von Domains unter Admins';
$lng['serversettings']['panel_allow_domain_change_admin']['description'] = 'Wenn diese Option aktiviert ist, kann unter Domaineinstellungen die Domain einem anderen Admin zugewiesen werden.<br /><b>Achtung:</b> Wenn der Kunde einer Domain nicht dem gleichen Admin zugeordnet ist wie die Domain selbst, kann dieser Admin alle anderen Domains des Kunden sehen!'; $lng['serversettings']['panel_allow_domain_change_admin']['description'] = 'Wenn diese Option aktiviert ist, kann unter Domaineinstellungen die Domain einem anderen Admin zugewiesen werden.<br /><b>Achtung:</b> Wenn der Kunde einer Domain nicht dem gleichen Admin zugeordnet ist wie die Domain selbst, kann dieser Admin alle anderen Domains des Kunden sehen!';
$lng['serversettings']['panel_allow_domain_change_customer']['title'] = 'Erlaube Verschieben von Domains unter Kunden'; $lng['serversettings']['panel_allow_domain_change_customer']['title'] = 'Erlaube Verschieben von Domains unter Kunden';
$lng['serversettings']['panel_allow_domain_change_customer']['description'] = 'Wenn diese Option aktiviert ist, kann unter Domaineinstellungen die Domain einem anderen Kunden zugewiesen werden.<br /><b>Achtung:</b> Es werden keine Pfade bei dieser Aktion angepasst. Das kann dazu führen, dass die Domain nach dem Verschieben nicht mehr richtig funktioniert!'; $lng['serversettings']['panel_allow_domain_change_customer']['description'] = 'Wenn diese Option aktiviert ist, kann unter Domaineinstellungen die Domain einem anderen Kunden zugewiesen werden.<br /><b>Achtung:</b> Der Dokumenten-Pfad der Domain wird auf den Heimatpfad (+ Domain-Ordner, sofern aktiviert) des neuen Kunden gesetzt.';
$lng['domains']['associated_with_domain'] = 'Verbunden mit'; $lng['domains']['associated_with_domain'] = 'Verbunden mit';
$lng['domains']['aliasdomains'] = 'Aliasdomains'; $lng['domains']['aliasdomains'] = 'Aliasdomains';
$lng['error']['ipportdoesntexist'] = 'Die gewählte IP/Port-Kombination existiert nicht.'; $lng['error']['ipportdoesntexist'] = 'Die gewählte IP/Port-Kombination existiert nicht.';
@@ -1525,6 +1525,7 @@ $lng['error']['autoupdate_7'] = 'Das heruntergeladene Archiv konnte nicht gefund
$lng['error']['autoupdate_8'] = 'Das Archiv konnte nicht entpackt werden :('; $lng['error']['autoupdate_8'] = 'Das Archiv konnte nicht entpackt werden :(';
$lng['error']['autoupdate_9'] = 'Die heruntergeladene Datei konnte nicht verifiziert werden. Bitte erneut versuchen zu aktualisieren.'; $lng['error']['autoupdate_9'] = 'Die heruntergeladene Datei konnte nicht verifiziert werden. Bitte erneut versuchen zu aktualisieren.';
$lng['error']['autoupdate_10'] = 'Minimum unterstützte Version von PHP ist 7.4.0'; $lng['error']['autoupdate_10'] = 'Minimum unterstützte Version von PHP ist 7.4.0';
$lng['error']['autoupdate_11'] = 'Webupdate ist deaktiviert';
$lng['domains']['termination_date'] = 'Kündigungsdatum'; $lng['domains']['termination_date'] = 'Kündigungsdatum';
$lng['domains']['termination_date_overview'] = 'gekündigt zum '; $lng['domains']['termination_date_overview'] = 'gekündigt zum ';