make unconfigured/unknown domain page a file-template
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user