2010-01-20 16:55:27 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2010-01-25 10:06:34 +00:00
|
|
|
* This file is part of the Froxlor project.
|
|
|
|
* Copyright (c) 2010 the Froxlor Team (see authors).
|
2010-01-20 16:55:27 +00:00
|
|
|
*
|
2022-04-28 18:48:00 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2010-01-20 16:55:27 +00:00
|
|
|
*
|
2022-04-28 18:48:00 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2011-05-04 09:59:20 +00:00
|
|
|
*
|
2022-04-28 18:48:00 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you can also view it online at
|
|
|
|
* https://files.froxlor.org/misc/COPYING.txt
|
|
|
|
*
|
|
|
|
* @copyright the authors
|
|
|
|
* @author Froxlor team <team@froxlor.org>
|
|
|
|
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
|
2010-01-20 16:55:27 +00:00
|
|
|
*/
|
2022-03-07 09:37:00 +00:00
|
|
|
|
2022-04-28 18:48:00 +00:00
|
|
|
use Froxlor\Api\Commands\Froxlor;
|
|
|
|
use Froxlor\Cron\TaskId;
|
2018-12-19 15:57:03 +00:00
|
|
|
use Froxlor\Database\Database;
|
2022-04-28 18:48:00 +00:00
|
|
|
use Froxlor\Database\IntegrityCheck;
|
|
|
|
use Froxlor\FroxlorLogger;
|
|
|
|
use Froxlor\PhpHelper;
|
2018-12-19 15:57:03 +00:00
|
|
|
use Froxlor\Settings;
|
2022-04-28 18:48:00 +00:00
|
|
|
use Froxlor\System\Cronjob;
|
|
|
|
use Froxlor\UI\Form;
|
|
|
|
use Froxlor\UI\HTML;
|
|
|
|
use Froxlor\UI\Listing;
|
2022-02-27 13:34:05 +00:00
|
|
|
use Froxlor\UI\Panel\UI;
|
2022-03-07 09:37:00 +00:00
|
|
|
use Froxlor\UI\Request;
|
2022-04-28 18:48:00 +00:00
|
|
|
use Froxlor\UI\Response;
|
|
|
|
use Froxlor\User;
|
|
|
|
use PHPMailer\PHPMailer\PHPMailer;
|
2018-12-18 09:49:18 +00:00
|
|
|
|
2022-02-20 17:00:44 +00:00
|
|
|
const AREA = 'admin';
|
|
|
|
require __DIR__ . '/lib/init.php';
|
2010-01-20 16:55:27 +00:00
|
|
|
|
2018-12-22 07:15:31 +00:00
|
|
|
if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
|
2022-04-28 18:48:00 +00:00
|
|
|
$settings_data = PhpHelper::loadConfigArrayDir('./actions/admin/settings/');
|
2018-12-22 14:52:20 +00:00
|
|
|
Settings::loadSettingsInto($settings_data);
|
2011-06-18 17:54:43 +00:00
|
|
|
|
2024-05-09 13:48:23 +00:00
|
|
|
if (Request::post('send') == 'send') {
|
2024-05-09 14:03:46 +00:00
|
|
|
$_part = Request::get('part', '');
|
2013-11-17 10:01:59 +00:00
|
|
|
if ($_part == '') {
|
2024-05-09 13:48:23 +00:00
|
|
|
$_part = Request::post('part', '');
|
2010-04-13 05:41:09 +00:00
|
|
|
}
|
|
|
|
|
2013-11-17 10:01:59 +00:00
|
|
|
if ($_part != '') {
|
|
|
|
if ($_part == 'all') {
|
2010-04-13 05:41:09 +00:00
|
|
|
$settings_all = true;
|
|
|
|
$settings_part = false;
|
2013-11-17 10:01:59 +00:00
|
|
|
} else {
|
2010-04-13 05:41:09 +00:00
|
|
|
$settings_all = false;
|
|
|
|
$settings_part = true;
|
|
|
|
}
|
|
|
|
$only_enabledisable = false;
|
2013-11-17 10:01:59 +00:00
|
|
|
} else {
|
2010-04-13 05:41:09 +00:00
|
|
|
$settings_all = false;
|
|
|
|
$settings_part = false;
|
|
|
|
$only_enabledisable = true;
|
|
|
|
}
|
2016-04-11 06:01:38 +00:00
|
|
|
|
2011-06-23 22:39:53 +00:00
|
|
|
// check if the session timeout is too low #815
|
2024-05-11 16:38:56 +00:00
|
|
|
if (!empty(Request::post('session_sessiontimeout')) && intval(Request::post('session_sessiontimeout', 0)) < 60) {
|
2023-06-12 11:06:18 +00:00
|
|
|
Response::standardError(['session_timeout', 'session_timeout_desc']);
|
2011-06-23 22:39:53 +00:00
|
|
|
}
|
2011-06-18 17:54:43 +00:00
|
|
|
|
2022-11-09 16:07:48 +00:00
|
|
|
try {
|
2024-05-09 13:48:23 +00:00
|
|
|
if (Form::processForm($settings_data, Request::postAll(), [
|
2018-12-19 15:57:03 +00:00
|
|
|
'filename' => $filename,
|
|
|
|
'action' => $action,
|
2023-07-10 11:40:48 +00:00
|
|
|
'page' => $page,
|
|
|
|
'part' => $_part,
|
2022-11-09 16:07:48 +00:00
|
|
|
], $_part, $settings_all, $settings_part, $only_enabledisable)) {
|
|
|
|
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "rebuild configfiles due to changed setting");
|
|
|
|
Cronjob::inserttask(TaskId::REBUILD_VHOST);
|
|
|
|
// Using nameserver, insert a task which rebuilds the server config
|
|
|
|
Cronjob::inserttask(TaskId::REBUILD_DNS);
|
|
|
|
// cron.d file
|
|
|
|
Cronjob::inserttask(TaskId::REBUILD_CRON);
|
|
|
|
|
|
|
|
Response::standardSuccess('settingssaved', '', [
|
|
|
|
'filename' => $filename,
|
|
|
|
'action' => $action,
|
|
|
|
'page' => $page
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
} catch (Exception $e) {
|
|
|
|
Response::dynamicError($e->getMessage(), $e->getCode());
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2013-11-17 10:01:59 +00:00
|
|
|
} else {
|
2024-05-09 14:03:46 +00:00
|
|
|
$_part = Request::get('part', '');
|
2013-11-17 10:01:59 +00:00
|
|
|
if ($_part == '') {
|
2024-05-09 13:48:23 +00:00
|
|
|
$_part = Request::post('part', '');
|
2010-04-13 05:41:09 +00:00
|
|
|
}
|
|
|
|
|
2022-04-28 18:48:00 +00:00
|
|
|
$fields = Form::buildForm($settings_data, $_part);
|
2011-06-18 17:54:43 +00:00
|
|
|
|
2022-02-27 13:37:32 +00:00
|
|
|
if ($_part == '' || $_part == 'all') {
|
2022-03-18 11:53:34 +00:00
|
|
|
UI::view('settings/index.html.twig', ['fields' => $fields]);
|
2013-11-17 10:01:59 +00:00
|
|
|
} else {
|
2022-12-30 20:43:27 +00:00
|
|
|
$em = Request::any('em', '');
|
2022-03-18 11:53:34 +00:00
|
|
|
UI::view('settings/detailpart.html.twig', ['fields' => $fields, 'em' => $em]);
|
2010-04-13 05:41:09 +00:00
|
|
|
}
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2018-12-22 07:15:31 +00:00
|
|
|
} elseif ($page == 'phpinfo' && $userinfo['change_serversettings'] == '1') {
|
2014-11-18 09:56:25 +00:00
|
|
|
ob_start();
|
|
|
|
phpinfo();
|
2022-04-28 18:48:00 +00:00
|
|
|
$phpinfo = [
|
|
|
|
'phpinfo' => []
|
|
|
|
];
|
2018-12-19 15:57:03 +00:00
|
|
|
if (preg_match_all('#(?:<h2>(?:<a name=".*?">)?(.*?)(?:</a>)?</h2>)|(?:<tr(?: class=".*?")?><t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>)?)?</tr>)#s', ob_get_clean(), $matches, PREG_SET_ORDER)) {
|
2013-10-02 07:48:24 +00:00
|
|
|
foreach ($matches as $match) {
|
|
|
|
$end = array_keys($phpinfo);
|
|
|
|
$end = end($end);
|
|
|
|
if (strlen($match[1])) {
|
2022-04-28 18:48:00 +00:00
|
|
|
$phpinfo[$match[1]] = [];
|
2013-10-02 07:48:24 +00:00
|
|
|
} elseif (isset($match[3])) {
|
2022-04-28 18:48:00 +00:00
|
|
|
$phpinfo[$end][$match[2]] = isset($match[4]) ? [
|
2018-12-19 15:57:03 +00:00
|
|
|
$match[3],
|
|
|
|
$match[4]
|
2022-04-28 18:48:00 +00:00
|
|
|
] : $match[3];
|
2013-10-02 07:48:24 +00:00
|
|
|
} else {
|
|
|
|
$phpinfo[$end][] = $match[2];
|
|
|
|
}
|
|
|
|
}
|
2014-11-18 09:56:25 +00:00
|
|
|
} else {
|
2023-06-12 11:06:18 +00:00
|
|
|
Response::standardError('error.no_phpinfo');
|
2013-10-02 07:48:24 +00:00
|
|
|
}
|
2022-03-24 14:10:00 +00:00
|
|
|
UI::view('settings/phpinfo.html.twig', [
|
|
|
|
'phpversion' => PHP_VERSION,
|
|
|
|
'phpinfo' => $phpinfo
|
|
|
|
]);
|
2018-12-22 07:15:31 +00:00
|
|
|
} elseif ($page == 'rebuildconfigs' && $userinfo['change_serversettings'] == '1') {
|
2024-05-09 13:48:23 +00:00
|
|
|
if (Request::post('send') == 'send') {
|
2022-04-28 18:48:00 +00:00
|
|
|
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "rebuild configfiles");
|
|
|
|
Cronjob::inserttask(TaskId::REBUILD_VHOST);
|
|
|
|
Cronjob::inserttask(TaskId::CREATE_QUOTA);
|
2013-03-29 19:10:37 +00:00
|
|
|
// Using nameserver, insert a task which rebuilds the server config
|
2022-04-28 18:48:00 +00:00
|
|
|
Cronjob::inserttask(TaskId::REBUILD_DNS);
|
2016-04-11 06:01:38 +00:00
|
|
|
// cron.d file
|
2022-04-28 18:48:00 +00:00
|
|
|
Cronjob::inserttask(TaskId::REBUILD_CRON);
|
2011-12-06 14:43:34 +00:00
|
|
|
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::standardSuccess('rebuildingconfigs', '', [
|
2018-12-19 15:57:03 +00:00
|
|
|
'filename' => 'admin_index.php'
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
2013-11-17 10:01:59 +00:00
|
|
|
} else {
|
2022-04-28 18:48:00 +00:00
|
|
|
HTML::askYesNo('admin_configs_reallyrebuild', $filename, [
|
2018-12-19 15:57:03 +00:00
|
|
|
'page' => $page
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2018-12-22 07:15:31 +00:00
|
|
|
} elseif ($page == 'updatecounters' && $userinfo['change_serversettings'] == '1') {
|
2024-05-09 13:48:23 +00:00
|
|
|
if (Request::post('send') == 'send') {
|
2022-04-28 18:48:00 +00:00
|
|
|
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_INFO, "updated resource-counters");
|
|
|
|
$updatecounters = User::updateCounters(true);
|
2022-03-27 12:58:52 +00:00
|
|
|
UI::view('user/resource-counter.html.twig', [
|
|
|
|
'counters' => $updatecounters
|
|
|
|
]);
|
2013-11-17 10:01:59 +00:00
|
|
|
} else {
|
2022-04-28 18:48:00 +00:00
|
|
|
HTML::askYesNo('admin_counters_reallyupdate', $filename, [
|
2018-12-19 15:57:03 +00:00
|
|
|
'page' => $page
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2018-12-22 07:15:31 +00:00
|
|
|
} elseif ($page == 'wipecleartextmailpws' && $userinfo['change_serversettings'] == '1') {
|
2024-05-09 13:48:23 +00:00
|
|
|
if (Request::post('send') == 'send') {
|
2022-04-28 18:48:00 +00:00
|
|
|
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_WARNING, "wiped all cleartext mail passwords");
|
2013-11-17 10:01:59 +00:00
|
|
|
Database::query("UPDATE `" . TABLE_MAIL_USERS . "` SET `password` = '';");
|
|
|
|
Database::query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '0' WHERE `settinggroup` = 'system' AND `varname` = 'mailpwcleartext'");
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::redirectTo($filename);
|
2013-11-17 10:01:59 +00:00
|
|
|
} else {
|
2022-04-28 18:48:00 +00:00
|
|
|
HTML::askYesNo('admin_cleartextmailpws_reallywipe', $filename, [
|
2018-12-19 15:57:03 +00:00
|
|
|
'page' => $page
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2018-12-22 07:15:31 +00:00
|
|
|
} elseif ($page == 'wipequotas' && $userinfo['change_serversettings'] == '1') {
|
2024-05-09 13:48:23 +00:00
|
|
|
if (Request::post('send') == 'send') {
|
2022-04-28 18:48:00 +00:00
|
|
|
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_WARNING, "wiped all mailquotas");
|
2010-01-20 16:55:27 +00:00
|
|
|
|
|
|
|
// Set the quota to 0 which means unlimited
|
2013-11-17 10:01:59 +00:00
|
|
|
Database::query("UPDATE `" . TABLE_MAIL_USERS . "` SET `quota` = '0';");
|
|
|
|
Database::query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `email_quota_used` = '0'");
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::redirectTo($filename);
|
2013-11-17 10:01:59 +00:00
|
|
|
} else {
|
2022-04-28 18:48:00 +00:00
|
|
|
HTML::askYesNo('admin_quotas_reallywipe', $filename, [
|
2018-12-19 15:57:03 +00:00
|
|
|
'page' => $page
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2018-12-22 07:15:31 +00:00
|
|
|
} elseif ($page == 'enforcequotas' && $userinfo['change_serversettings'] == '1') {
|
2024-05-09 13:48:23 +00:00
|
|
|
if (Request::post('send') == 'send') {
|
2010-01-20 16:55:27 +00:00
|
|
|
// Fetch all accounts
|
2013-11-17 10:01:59 +00:00
|
|
|
$result_stmt = Database::query("SELECT `quota`, `customerid` FROM `" . TABLE_MAIL_USERS . "`");
|
|
|
|
|
|
|
|
if (Database::num_rows() > 0) {
|
|
|
|
$upd_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET
|
|
|
|
`email_quota_used` = `email_quota_used` + :diff
|
|
|
|
WHERE `customerid` = :customerid
|
|
|
|
");
|
2010-01-20 16:55:27 +00:00
|
|
|
|
2013-11-17 10:01:59 +00:00
|
|
|
while ($array = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2013-12-15 10:47:23 +00:00
|
|
|
$difference = Settings::Get('system.mail_quota') - $array['quota'];
|
2022-04-28 18:48:00 +00:00
|
|
|
Database::pexecute($upd_stmt, [
|
2018-12-19 15:57:03 +00:00
|
|
|
'diff' => $difference,
|
|
|
|
'customerid' => $customerid
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
2013-11-17 10:01:59 +00:00
|
|
|
}
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set the new quota
|
2013-11-17 10:01:59 +00:00
|
|
|
$upd_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_MAIL_USERS . "` SET `quota` = :quota
|
|
|
|
");
|
2022-04-28 18:48:00 +00:00
|
|
|
Database::pexecute($upd_stmt, [
|
2018-12-19 15:57:03 +00:00
|
|
|
'quota' => Settings::Get('system.mail_quota')
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
2010-01-20 16:55:27 +00:00
|
|
|
|
|
|
|
// Update the Customer, if the used quota is bigger than the allowed quota
|
2013-11-17 10:01:59 +00:00
|
|
|
Database::query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `email_quota` = `email_quota_used` WHERE `email_quota` < `email_quota_used`");
|
2022-04-28 18:48:00 +00:00
|
|
|
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_WARNING, 'enforcing mailquota to all customers: ' . Settings::Get('system.mail_quota') . ' MB');
|
|
|
|
Response::redirectTo($filename);
|
2013-11-17 10:01:59 +00:00
|
|
|
} else {
|
2022-04-28 18:48:00 +00:00
|
|
|
HTML::askYesNo('admin_quotas_reallyenforce', $filename, [
|
2018-12-19 15:57:03 +00:00
|
|
|
'page' => $page
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2018-12-22 07:15:31 +00:00
|
|
|
} elseif ($page == 'integritycheck' && $userinfo['change_serversettings'] == '1') {
|
2022-04-28 18:48:00 +00:00
|
|
|
$integrity = new IntegrityCheck();
|
2024-05-09 13:48:23 +00:00
|
|
|
if (Request::post('send') == 'send') {
|
2014-02-11 15:40:53 +00:00
|
|
|
$integrity->fixAll();
|
2024-05-09 14:03:46 +00:00
|
|
|
} elseif (Request::get('action') == "fix") {
|
2022-04-28 18:48:00 +00:00
|
|
|
HTML::askYesNo('admin_integritycheck_reallyfix', $filename, [
|
2018-12-19 15:57:03 +00:00
|
|
|
'page' => $page
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
2014-02-11 15:40:53 +00:00
|
|
|
}
|
|
|
|
|
2022-03-14 11:36:53 +00:00
|
|
|
$integritycheck = [];
|
2014-02-11 15:40:53 +00:00
|
|
|
foreach ($integrity->available as $id => $check) {
|
2022-03-14 11:36:53 +00:00
|
|
|
$integritycheck[] = [
|
|
|
|
'displayid' => $id + 1,
|
|
|
|
'result' => $integrity->$check(),
|
2022-04-28 18:48:00 +00:00
|
|
|
'checkdesc' => lng('integrity_check.' . $check)
|
2022-03-14 11:36:53 +00:00
|
|
|
];
|
2014-02-11 15:40:53 +00:00
|
|
|
}
|
2022-03-14 11:36:53 +00:00
|
|
|
|
|
|
|
$integrity_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.integrity.php';
|
|
|
|
$collection = [
|
|
|
|
'data' => $integritycheck,
|
|
|
|
'pagination' => []
|
|
|
|
];
|
|
|
|
|
2022-03-18 11:53:34 +00:00
|
|
|
UI::view('user/table.html.twig', [
|
2022-10-16 11:35:50 +00:00
|
|
|
'listing' => Listing::formatFromArray($collection, $integrity_list_data['integrity_list'], 'integrity_list'),
|
2022-04-28 18:48:00 +00:00
|
|
|
'actions_links' => [
|
|
|
|
[
|
|
|
|
'href' => $linker->getLink(['section' => 'settings', 'page' => $page, 'action' => 'fix']),
|
|
|
|
'label' => lng('admin.integrityfix'),
|
|
|
|
'icon' => 'fa-solid fa-screwdriver-wrench',
|
|
|
|
'class' => 'btn-warning'
|
|
|
|
]
|
|
|
|
]
|
2022-03-14 11:36:53 +00:00
|
|
|
]);
|
2018-12-22 07:15:31 +00:00
|
|
|
} elseif ($page == 'importexport' && $userinfo['change_serversettings'] == '1') {
|
2018-01-30 06:58:24 +00:00
|
|
|
// check for json-stuff
|
2022-03-07 09:37:00 +00:00
|
|
|
if (!extension_loaded('json')) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::standardError('jsonextensionnotfound');
|
2018-01-30 06:58:24 +00:00
|
|
|
}
|
|
|
|
|
2024-05-09 14:03:46 +00:00
|
|
|
if (Request::get('action') == "export") {
|
2018-01-28 13:33:00 +00:00
|
|
|
// export
|
|
|
|
try {
|
2018-12-22 07:15:31 +00:00
|
|
|
$json_result = Froxlor::getLocal($userinfo)->exportSettings();
|
2018-11-25 10:17:56 +00:00
|
|
|
$json_export = json_decode($json_result, true)['data'];
|
2018-12-19 15:57:03 +00:00
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($e->getMessage());
|
2018-01-28 13:33:00 +00:00
|
|
|
}
|
2022-04-03 16:42:49 +00:00
|
|
|
header('Content-disposition: attachment; filename=Froxlor_settings-' . \Froxlor\Froxlor::VERSION . '-' . \Froxlor\Froxlor::DBVERSION . '_' . date('d.m.Y') . '.json');
|
2018-01-28 13:33:00 +00:00
|
|
|
header('Content-type: application/json');
|
|
|
|
echo $json_export;
|
2018-12-19 15:57:03 +00:00
|
|
|
exit();
|
2024-05-09 14:03:46 +00:00
|
|
|
} elseif (Request::get('action') == "import") {
|
2018-01-28 13:33:00 +00:00
|
|
|
// import
|
2024-05-09 13:48:23 +00:00
|
|
|
if (Request::post('send') == 'send') {
|
2018-01-28 13:33:00 +00:00
|
|
|
// get uploaded file
|
|
|
|
if (isset($_FILES["import_file"]["tmp_name"])) {
|
|
|
|
$imp_content = file_get_contents($_FILES["import_file"]["tmp_name"]);
|
|
|
|
try {
|
2022-04-28 18:48:00 +00:00
|
|
|
Froxlor::getLocal($userinfo, [
|
2018-12-19 15:57:03 +00:00
|
|
|
'json_str' => $imp_content
|
2022-04-28 18:48:00 +00:00
|
|
|
])->importSettings();
|
2018-12-19 15:57:03 +00:00
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($e->getMessage());
|
2018-01-28 13:33:00 +00:00
|
|
|
}
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::standardSuccess('settingsimported', '', [
|
2018-12-19 15:57:03 +00:00
|
|
|
'filename' => 'admin_settings.php'
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
2018-01-28 13:33:00 +00:00
|
|
|
}
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError("Upload failed");
|
2018-01-28 13:33:00 +00:00
|
|
|
}
|
|
|
|
} else {
|
2022-03-16 12:22:59 +00:00
|
|
|
$settings_data = include_once dirname(__FILE__) . '/lib/formfields/admin/settings/formfield.settings_import.php';
|
|
|
|
|
2022-03-18 11:53:34 +00:00
|
|
|
UI::view('user/form.html.twig', [
|
2022-04-28 18:48:00 +00:00
|
|
|
'formaction' => $linker->getLink(['section' => 'settings', 'page' => $page, 'action' => 'import']),
|
2022-03-16 12:22:59 +00:00
|
|
|
'formdata' => $settings_data['settings_import'],
|
2022-04-28 18:48:00 +00:00
|
|
|
'actions_links' => [
|
|
|
|
[
|
|
|
|
'class' => 'btn-outline-primary',
|
|
|
|
'href' => $linker->getLink(['section' => 'settings', 'page' => 'overview']),
|
|
|
|
'label' => lng('admin.configfiles.overview'),
|
2022-09-08 11:13:06 +00:00
|
|
|
'icon' => 'fa-solid fa-grip'
|
2022-04-28 18:48:00 +00:00
|
|
|
],
|
|
|
|
[
|
|
|
|
'class' => 'btn-outline-secondary',
|
|
|
|
'href' => $linker->getLink(['section' => 'settings', 'page' => $page, 'action' => 'export']),
|
|
|
|
'label' => 'Download/export ' . lng('admin.serversettings'),
|
2022-09-08 11:13:06 +00:00
|
|
|
'icon' => 'fa-solid fa-file-import'
|
2022-04-28 18:48:00 +00:00
|
|
|
]
|
|
|
|
]
|
2022-03-16 12:22:59 +00:00
|
|
|
]);
|
2018-01-28 13:33:00 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
} elseif ($page == 'testmail') {
|
2022-03-24 13:25:29 +00:00
|
|
|
$note_type = 'info';
|
2022-04-28 18:48:00 +00:00
|
|
|
$note_msg = lng('admin.smtptestnote');
|
2022-03-24 13:25:29 +00:00
|
|
|
|
2024-05-09 13:48:23 +00:00
|
|
|
if (Request::post('send') == 'send') {
|
|
|
|
$test_addr = Request::post('test_addr');
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2022-03-24 13:25:29 +00:00
|
|
|
// Initialize the mailingsystem
|
2022-04-28 18:48:00 +00:00
|
|
|
$testmail = new PHPMailer(true);
|
2018-12-19 15:57:03 +00:00
|
|
|
$testmail->CharSet = "UTF-8";
|
|
|
|
|
|
|
|
if (Settings::Get('system.mail_use_smtp')) {
|
|
|
|
$testmail->isSMTP();
|
|
|
|
$testmail->Host = Settings::Get('system.mail_smtp_host');
|
2022-04-14 07:02:10 +00:00
|
|
|
$testmail->SMTPAuth = Settings::Get('system.mail_smtp_auth') == '1';
|
2018-12-19 15:57:03 +00:00
|
|
|
$testmail->Username = Settings::Get('system.mail_smtp_user');
|
|
|
|
$testmail->Password = Settings::Get('system.mail_smtp_passwd');
|
|
|
|
if (Settings::Get('system.mail_smtp_usetls')) {
|
|
|
|
$testmail->SMTPSecure = 'tls';
|
|
|
|
} else {
|
|
|
|
$testmail->SMTPAutoTLS = false;
|
2017-08-25 08:34:59 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
$testmail->Port = Settings::Get('system.mail_smtp_port');
|
|
|
|
}
|
2017-08-25 08:34:59 +00:00
|
|
|
|
2018-12-19 15:57:03 +00:00
|
|
|
$_mailerror = false;
|
2022-04-28 18:48:00 +00:00
|
|
|
if (PHPMailer::ValidateAddress(Settings::Get('panel.adminmail')) !== false) {
|
2018-12-19 15:57:03 +00:00
|
|
|
// set return-to address and custom sender-name, see #76
|
|
|
|
$testmail->SetFrom(Settings::Get('panel.adminmail'), Settings::Get('panel.adminmail_defname'));
|
|
|
|
if (Settings::Get('panel.adminmail_return') != '') {
|
|
|
|
$testmail->AddReplyTo(Settings::Get('panel.adminmail_return'), Settings::Get('panel.adminmail_defname'));
|
|
|
|
}
|
2017-08-25 08:34:59 +00:00
|
|
|
|
2018-12-19 15:57:03 +00:00
|
|
|
try {
|
|
|
|
$testmail->Subject = "Froxlor Test-Mail";
|
|
|
|
$mail_body = "Yay, this worked :)";
|
|
|
|
$testmail->AltBody = $mail_body;
|
|
|
|
$testmail->MsgHTML(str_replace("\n", "<br />", $mail_body));
|
|
|
|
$testmail->AddAddress($test_addr);
|
|
|
|
$testmail->Send();
|
|
|
|
} catch (\PHPMailer\PHPMailer\Exception $e) {
|
2022-03-24 13:25:29 +00:00
|
|
|
$note_type = 'danger';
|
|
|
|
$note_msg = $e->getMessage();
|
2018-12-19 15:57:03 +00:00
|
|
|
$_mailerror = true;
|
|
|
|
} catch (Exception $e) {
|
2022-03-24 13:25:29 +00:00
|
|
|
$note_type = 'danger';
|
|
|
|
$note_msg = $e->getMessage();
|
2017-08-25 08:34:59 +00:00
|
|
|
$_mailerror = true;
|
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
|
2022-03-07 09:37:00 +00:00
|
|
|
if (!$_mailerror) {
|
2018-12-19 15:57:03 +00:00
|
|
|
// success
|
|
|
|
$mail->ClearAddresses();
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::standardSuccess('testmailsent', '', [
|
2018-12-19 15:57:03 +00:00
|
|
|
'filename' => 'admin_settings.php',
|
|
|
|
'page' => 'testmail'
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
2018-12-19 15:57:03 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// invalid sender e-mail
|
2022-03-24 13:25:29 +00:00
|
|
|
$note_type = 'warning';
|
|
|
|
$note_msg = "Invalid sender e-mail address: " . Settings::Get('panel.adminmail');
|
2017-08-25 08:34:59 +00:00
|
|
|
}
|
2018-12-19 15:57:03 +00:00
|
|
|
}
|
2017-08-25 08:34:59 +00:00
|
|
|
|
2022-03-24 13:25:29 +00:00
|
|
|
$mailtest_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/settings/formfield.settings_mailtest.php';
|
2017-08-25 08:34:59 +00:00
|
|
|
|
2022-03-24 13:25:29 +00:00
|
|
|
UI::view('user/form-note.html.twig', [
|
2022-04-28 18:48:00 +00:00
|
|
|
'formaction' => $linker->getLink(['section' => 'settings']),
|
2022-03-24 13:25:29 +00:00
|
|
|
'formdata' => $mailtest_add_data['mailtest'],
|
2022-04-28 18:48:00 +00:00
|
|
|
'actions_links' => [
|
|
|
|
[
|
|
|
|
'href' => $linker->getLink([
|
|
|
|
'section' => 'settings',
|
|
|
|
'page' => 'overview',
|
|
|
|
'part' => 'system',
|
|
|
|
'em' => 'system_mail_use_smtp'
|
|
|
|
]),
|
|
|
|
'label' => lng('admin.smtpsettings'),
|
|
|
|
'icon' => 'fa-solid fa-gears',
|
|
|
|
'class' => 'btn-outline-secondary'
|
|
|
|
]
|
|
|
|
],
|
2022-03-24 13:25:29 +00:00
|
|
|
// alert-box
|
|
|
|
'type' => $note_type,
|
|
|
|
'alert_msg' => $note_msg
|
|
|
|
]);
|
2022-04-08 13:53:20 +00:00
|
|
|
} elseif ($page == 'toggleSettingsMode') {
|
|
|
|
if ($userinfo['change_serversettings'] == '1') {
|
|
|
|
$cmode = Settings::Get('panel.settings_mode');
|
|
|
|
Settings::Set('panel.settings_mode', (int)(!(bool)$cmode));
|
|
|
|
}
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::redirectTo($filename);
|
2017-08-25 08:34:59 +00:00
|
|
|
}
|