make unconfigured/unknown domain page a file-template
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -172,16 +172,6 @@ return [
|
||||
'default' => false,
|
||||
'save_method' => 'storeSettingField'
|
||||
],
|
||||
'system_index_file_extension' => [
|
||||
'label' => lng('serversettings.index_file_extension'),
|
||||
'settinggroup' => 'system',
|
||||
'varname' => 'index_file_extension',
|
||||
'type' => 'text',
|
||||
'string_regexp' => '/^[a-zA-Z0-9]{1,6}$/',
|
||||
'default' => 'html',
|
||||
'save_method' => 'storeSettingField',
|
||||
'advanced_mode' => true
|
||||
],
|
||||
'system_store_index_file_subs' => [
|
||||
'label' => lng('serversettings.system_store_index_file_subs'),
|
||||
'settinggroup' => 'system',
|
||||
|
||||
@@ -60,7 +60,8 @@ if (Settings::Get('panel.sendalternativemail') == 1) {
|
||||
}
|
||||
|
||||
$file_templates = [
|
||||
'index_html'
|
||||
'index_html',
|
||||
'unconfigured_html'
|
||||
];
|
||||
|
||||
$languages = Language::getLanguages();
|
||||
|
||||
@@ -562,7 +562,6 @@ opcache.validate_timestamps'),
|
||||
('system', 'mod_fcgid_wrapper', '1'),
|
||||
('system', 'mod_fcgid_starter', '0'),
|
||||
('system', 'mod_fcgid_peardir', '/usr/share/php/:/usr/share/php5/'),
|
||||
('system', 'index_file_extension', 'html'),
|
||||
('system', 'mod_fcgid_maxrequests', '250'),
|
||||
('system', 'ssl_key_file','/etc/ssl/froxlor_selfsigned.key'),
|
||||
('system', 'ssl_ca_file', ''),
|
||||
@@ -728,7 +727,7 @@ opcache.validate_timestamps'),
|
||||
('panel', 'settings_mode', '0'),
|
||||
('panel', 'menu_collapsed', '1'),
|
||||
('panel', 'version', '2.1.0-rc2'),
|
||||
('panel', 'db_version', '202305240');
|
||||
('panel', 'db_version', '202311260');
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `panel_tasks`;
|
||||
|
||||
@@ -123,3 +123,18 @@ if (Froxlor::isFroxlorVersion('2.1.0-rc1')) {
|
||||
|
||||
Froxlor::updateToVersion('2.1.0-rc2');
|
||||
}
|
||||
|
||||
if (Froxlor::isDatabaseVersion('202305240')) {
|
||||
|
||||
Update::showUpdateStep("Adjusting file-template file extension setttings");
|
||||
$current_fileextension = Settings::Get('system.index_file_extension');
|
||||
Database::query("DELETE FROM `" . TABLE_PANEL_SETTINGS . "` WHERE `settinggroup`= 'system' AND `varname`= 'index_file_extension'");
|
||||
Database::query("ALTER TABLE `" . TABLE_PANEL_TEMPLATES . "` ADD `file_extension` varchar(50) NOT NULL default 'html';");
|
||||
if (strtolower(trim($current_fileextension)) != 'html') {
|
||||
$stmt = Database::prepare("UPDATE TABLE `" . TABLE_PANEL_TEMPLATES . "` SET `file_extension` = :ext WHERE `templategroup` = 'files'");
|
||||
Database::pexecute($stmt, ['ext' => strtolower(trim($current_fileextension))]);
|
||||
}
|
||||
Update::lastStepStatus(0);
|
||||
|
||||
Froxlor::updateToDbVersion('202311260');
|
||||
}
|
||||
|
||||
@@ -257,6 +257,36 @@ class FileDir
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read unconfigured-domain template from database if exists or fallback to default
|
||||
*
|
||||
* @param string $servername
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getUnknownDomainTemplate(string $servername = "")
|
||||
{
|
||||
$result_stmt = Database::prepare("
|
||||
SELECT * FROM `" . TABLE_PANEL_TEMPLATES . "` WHERE `templategroup` = 'files' AND `varname` = 'unconfigured_html'
|
||||
");
|
||||
Database::pexecute($result_stmt);
|
||||
if (Database::num_rows() > 0) {
|
||||
$template = $result_stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$replace_arr = [
|
||||
'SERVERNAME' => $servername,
|
||||
];
|
||||
$tpl_content = PhpHelper::replaceVariables($template['value'], $replace_arr);
|
||||
} else {
|
||||
$unconfiguredPath = FileDir::makeCorrectFile(Froxlor::getInstallDir() . '/templates/misc/unconfigured/index.html');
|
||||
if (file_exists($unconfiguredPath)) {
|
||||
$tpl_content = file_get_contents($unconfiguredPath);
|
||||
} else {
|
||||
$tpl_content = lng('admin.templates.unconfigured_content_fallback');
|
||||
}
|
||||
}
|
||||
return $tpl_content;
|
||||
}
|
||||
|
||||
/**
|
||||
* store the default index-file in a given destination folder
|
||||
*
|
||||
@@ -277,7 +307,7 @@ class FileDir
|
||||
{
|
||||
if ($force || (int)Settings::Get('system.store_index_file_subs') == 1) {
|
||||
$result_stmt = Database::prepare("
|
||||
SELECT `t`.`value`, `c`.`email` AS `customer_email`, `a`.`email` AS `admin_email`, `c`.`loginname` AS `customer_login`, `a`.`loginname` AS `admin_login`
|
||||
SELECT `t`.`value`, `t`.`file_extension`, `c`.`email` AS `customer_email`, `a`.`email` AS `admin_email`, `c`.`loginname` AS `customer_login`, `a`.`loginname` AS `admin_login`
|
||||
FROM `" . TABLE_PANEL_CUSTOMERS . "` AS `c` INNER JOIN `" . TABLE_PANEL_ADMINS . "` AS `a`
|
||||
ON `c`.`adminid` = `a`.`adminid`
|
||||
INNER JOIN `" . TABLE_PANEL_TEMPLATES . "` AS `t`
|
||||
@@ -300,7 +330,7 @@ class FileDir
|
||||
|
||||
// replaceVariables
|
||||
$htmlcontent = PhpHelper::replaceVariables($template['value'], $replace_arr);
|
||||
$indexhtmlpath = self::makeCorrectFile($destination . '/index.' . Settings::Get('system.index_file_extension'));
|
||||
$indexhtmlpath = self::makeCorrectFile($destination . '/index.' . $template['file_extension']);
|
||||
$index_html_handler = fopen($indexhtmlpath, 'w');
|
||||
fwrite($index_html_handler, $htmlcontent);
|
||||
fclose($index_html_handler);
|
||||
@@ -308,7 +338,7 @@ class FileDir
|
||||
$logger->logAction(
|
||||
FroxlorLogger::CRON_ACTION,
|
||||
LOG_NOTICE,
|
||||
'Creating \'index.' . Settings::Get('system.index_file_extension') . '\' for Customer \'' . $template['customer_login'] . '\' based on template in directory ' . escapeshellarg($indexhtmlpath)
|
||||
'Creating \'index.' . $template['file_extension'] . '\' for Customer \'' . $template['customer_login'] . '\' based on template in directory ' . escapeshellarg($indexhtmlpath)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -34,7 +34,7 @@ final class Froxlor
|
||||
const VERSION = '2.1.0-rc2';
|
||||
|
||||
// Database version (YYYYMMDDC where C is a daily counter)
|
||||
const DBVERSION = '202305240';
|
||||
const DBVERSION = '202311260';
|
||||
|
||||
// Distribution branding-tag (used for Debian etc.)
|
||||
const BRANDING = '';
|
||||
|
||||
@@ -38,11 +38,20 @@ return [
|
||||
'type' => 'select',
|
||||
'select_var' => $free_templates
|
||||
],
|
||||
'file_extension' => [
|
||||
'label' => lng('admin.templates.file_extension'),
|
||||
'type' => 'text',
|
||||
'string_regexp' => '/^[a-zA-Z0-9]{1,6}$/',
|
||||
'default' => 'html',
|
||||
'value' => 'html',
|
||||
'mandatory' => true
|
||||
],
|
||||
'filecontent' => [
|
||||
'label' => lng('admin.templates.filecontent'),
|
||||
'type' => 'textarea',
|
||||
'cols' => 60,
|
||||
'rows' => 12
|
||||
'rows' => 12,
|
||||
'mandatory' => true
|
||||
],
|
||||
'filesend' => [
|
||||
'type' => 'hidden',
|
||||
|
||||
@@ -39,12 +39,21 @@ return [
|
||||
'value' => lng('admin.templates.' . $row['varname']),
|
||||
'display' => lng('admin.templates.' . $row['varname'])
|
||||
],
|
||||
'file_extension' => [
|
||||
'label' => lng('admin.templates.file_extension'),
|
||||
'type' => 'text',
|
||||
'string_regexp' => '/^[a-zA-Z0-9]{1,6}$/',
|
||||
'value' => $row['file_extension'],
|
||||
'default' => 'html',
|
||||
'mandatory' => true
|
||||
],
|
||||
'filecontent' => [
|
||||
'label' => lng('admin.templates.filecontent'),
|
||||
'type' => 'textarea',
|
||||
'cols' => 60,
|
||||
'rows' => 12,
|
||||
'value' => $row['value']
|
||||
'value' => $row['value'],
|
||||
'mandatory' => true
|
||||
],
|
||||
'filesend' => [
|
||||
'type' => 'hidden',
|
||||
|
||||
@@ -121,12 +121,8 @@ if ($_SERVER['SERVER_NAME'] != Settings::Get('system.hostname') &&
|
||||
(!empty(Settings::Get('system.froxloraliases')) && !in_array($_SERVER['SERVER_NAME'], array_map('trim', explode(',', Settings::Get('system.froxloraliases')))))
|
||||
)) {
|
||||
// not the froxlor system-hostname, show info page for domains not configured in froxlor
|
||||
$unconfiguredPath = FileDir::makeCorrectFile(Froxlor::getInstallDir() . '/templates/misc/unconfigured/index.html');
|
||||
if (file_exists($unconfiguredPath)) {
|
||||
echo file_get_contents($unconfiguredPath);
|
||||
} else {
|
||||
echo "This domain requires configuration via the froxlor server management panel, as it is currently not assigned to any customer.";
|
||||
}
|
||||
$output = FileDir::getUnknownDomainTemplate($_SERVER['SERVER_NAME']);
|
||||
echo $output;
|
||||
die();
|
||||
}
|
||||
|
||||
|
||||
@@ -140,12 +140,18 @@ return [
|
||||
'TRAFFICUSED' => 'Wird mit Traffic, der vom Kunden bereits verbraucht wurde, ersetzt.',
|
||||
'pop_success_alternative' => 'Willkommensmail für neue E-Mail-Konten für die alternative E-Mail-Adresse',
|
||||
'EMAIL_PASSWORD' => 'Wird mit dem Passwort des neuen POP3/IMAP Kontos ersetzt.',
|
||||
'index_html' => 'index.html Datei für neu erzeugte Kundenverzeichnisse',
|
||||
'index_html' => 'index Datei für neu erzeugte Kundenverzeichnisse',
|
||||
'unconfigured_html' => 'index Datei für unkonfigurierte/unbekannte Domains',
|
||||
'unconfigured_content_fallback' => 'Diese Domain muss über das Froxlor-Serververwaltungspanel konfiguriert werden, da sie derzeit keinem Kunden zugewiesen ist.',
|
||||
'file_extension' => [
|
||||
'description' => 'Die Dateiendung für die index Datei muss zwischen 1 und 6 Zeichen lang sein und darf nur aus den Zeichen a-z, A-Z und 0-9 bestehen<br><br>Standard: html',
|
||||
'title' => 'Dateiendung für Datei Vorlage',
|
||||
],
|
||||
'SERVERNAME' => 'Wird mit dem Servernamen ersetzt.',
|
||||
'CUSTOMER' => 'Wird mit dem Loginnamen des Kunden ersetzt.',
|
||||
'ADMIN' => 'Wird mit dem Loginnamen des Admins ersetzt.',
|
||||
'CUSTOMER_EMAIL' => 'Wird mit der E-Mail-Adresse des Kunden ersetzt.',
|
||||
'ADMIN_EMAIL' => 'Wird mit der E-Mail-Adresse des Admin ersetzt.',
|
||||
'CUSTOMER' => 'Wird mit dem Loginnamen des Kunden ersetzt. Nur für "index Datei für neu erzeugte Kundenverzeichnisse".',
|
||||
'ADMIN' => 'Wird mit dem Loginnamen des Admins ersetzt. Nur für "index Datei für neu erzeugte Kundenverzeichnisse".',
|
||||
'CUSTOMER_EMAIL' => 'Wird mit der E-Mail-Adresse des Kunden ersetzt. Nur für "index Datei für neu erzeugte Kundenverzeichnisse".',
|
||||
'ADMIN_EMAIL' => 'Wird mit der E-Mail-Adresse des Admin ersetzt. Nur für "index Datei für neu erzeugte Kundenverzeichnisse".',
|
||||
'filetemplates' => 'Dateivorlagen',
|
||||
'filecontent' => 'Dateiinhalt',
|
||||
'new_database_by_customer' => 'Kunden-Benachrichtigungs nach Erstellung einer neuen Datenbank',
|
||||
@@ -831,7 +837,6 @@ return [
|
||||
'descriptioninvalid' => 'Der Beschreibungstext ist zu kurz, zu lang oder enthält ungültige Zeichen',
|
||||
'info' => 'Info',
|
||||
'filecontentnotset' => 'Diese Datei darf nicht leer sein!',
|
||||
'index_file_extension' => 'Die Dateiendung für die index Datei muss zwischen 1 und 6 Zeichen lang sein und darf nur aus den Zeichen a-z, A-Z und 0-9 bestehen',
|
||||
'customerdoesntexist' => 'Der ausgewählte Kunde existiert nicht.',
|
||||
'admindoesntexist' => 'Der ausgewählte Admin existiert nicht.',
|
||||
'ipportdoesntexist' => 'Die gewählte IP/Port-Kombination existiert nicht.',
|
||||
@@ -1610,10 +1615,6 @@ Vielen Dank, Ihr Administrator',
|
||||
'removelink' => 'Hier klicken, um alle E-Mail-Kontingente zu entfernen',
|
||||
'enforcelink' => 'Hier klicken, um allen Benutzern das Standard-Kontingent zu zuweisen.',
|
||||
],
|
||||
'index_file_extension' => [
|
||||
'description' => 'Welche Dateiendung soll die index Datei in neu erstellten Kundenverzeichnissen haben? Diese Dateiendung wird dann verwendet, wenn Sie bzw. einer Ihrer Admins eigene index Dateivorlagen erstellt haben.',
|
||||
'title' => 'Dateiendung für index Datei in neu erstellen Kundenverzeichnissen',
|
||||
],
|
||||
'session_allow_multiple_login' => [
|
||||
'title' => 'Erlaube gleichzeitigen Login',
|
||||
'description' => 'Wenn diese Option aktiviert ist, können sich Nutzer mehrmals gleichzeitig anmelden.',
|
||||
|
||||
@@ -144,11 +144,17 @@ return [
|
||||
'pop_success_alternative' => 'Welcome mail for new email accounts sent to alternative address',
|
||||
'EMAIL_PASSWORD' => 'Replaced with the POP3/IMAP account password.',
|
||||
'index_html' => 'index file for newly created customer directories',
|
||||
'unconfigured_html' => 'index file for unconfigured/unknown domains',
|
||||
'unconfigured_content_fallback' => 'This domain requires configuration via the froxlor server management panel, as it is currently not assigned to any customer.',
|
||||
'file_extension' => [
|
||||
'description' => 'The file extension for the index file must be between 1 and 6 characters long. The extension can only contain characters like a-z, A-Z and 0-9<br><br>Default: html',
|
||||
'title' => 'File extension for the file template',
|
||||
],
|
||||
'SERVERNAME' => 'Replaced with the servername.',
|
||||
'CUSTOMER' => 'Replaced with the loginname of the customer.',
|
||||
'ADMIN' => 'Replaced with the loginname of the admin.',
|
||||
'CUSTOMER_EMAIL' => 'Replaced with the e-mail address of the customer.',
|
||||
'ADMIN_EMAIL' => 'Replaced with the e-mail address of the admin.',
|
||||
'CUSTOMER' => 'Replaced with the loginname of the customer. Only for "index file for newly created customer directories"',
|
||||
'ADMIN' => 'Replaced with the loginname of the admin. Only for "index file for newly created customer directories"',
|
||||
'CUSTOMER_EMAIL' => 'Replaced with the e-mail address of the customer. Only for "index file for newly created customer directories"',
|
||||
'ADMIN_EMAIL' => 'Replaced with the e-mail address of the admin. Only for "index file for newly created customer directories"',
|
||||
'filetemplates' => 'File templates',
|
||||
'filecontent' => 'File content',
|
||||
'new_database_by_customer' => 'Customer-notification when a database has been created',
|
||||
@@ -903,7 +909,6 @@ return [
|
||||
'descriptioninvalid' => 'The description is too short, too long or contains illegal characters.',
|
||||
'info' => 'Info',
|
||||
'filecontentnotset' => 'The file cannot be empty!',
|
||||
'index_file_extension' => 'The file extension for the index file must be between 1 and 6 characters long. The extension can only contain characters like a-z, A-Z and 0-9',
|
||||
'customerdoesntexist' => 'The customer you have chosen doesn\'t exist.',
|
||||
'admindoesntexist' => 'The admin you have chosen doesn\'t exist.',
|
||||
'ipportdoesntexist' => 'The ip/port combination you have chosen doesn\'t exist.',
|
||||
@@ -1732,10 +1737,6 @@ Yours sincerely, your administrator',
|
||||
'removelink' => 'Click here to wipe all quotas for mail accounts.',
|
||||
'enforcelink' => 'Click here to enforce default quota to all User mail accounts.',
|
||||
],
|
||||
'index_file_extension' => [
|
||||
'description' => 'Which file extension should be used for the index file in newly created customer directories? This file extension will be used, if you or one of your admins has created its own index file template.',
|
||||
'title' => 'File extension for index file in newly created customer directories',
|
||||
],
|
||||
'session_allow_multiple_login' => [
|
||||
'title' => 'Allow multiple login',
|
||||
'description' => 'If activated a user could login multiple times.',
|
||||
|
||||
Reference in New Issue
Block a user