diff --git a/admin_message.php b/admin_message.php index 4482345575..44ac65e3cc 100644 --- a/admin_message.php +++ b/admin_message.php @@ -114,7 +114,7 @@ $note_msg = lng('message.norecipients'); } else { $note_type = 'success'; - $note_msg = str_replace('%s', $sentitems, lng('message.success')); + $note_msg = lng('message.success', [$sentitems]); } } @@ -128,7 +128,7 @@ $messages_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/messages/formfield.messages_add.php'; UI::view('user/form-note.html.twig', [ - 'formaction' => $linker->getLink(['section' => 'message']), + 'formaction' => $linker->getLink(['section' => 'message', 'action' => '']), 'formdata' => $messages_add_data['messages_add'], 'actions_links' => [ [ diff --git a/customer_email.php b/customer_email.php index dc55aed083..b3f6c25127 100644 --- a/customer_email.php +++ b/customer_email.php @@ -247,11 +247,7 @@ if (isset($result['email']) && $result['email'] != '') { if (Request::post('send') == 'send') { try { - Emails::getLocal($userinfo, [ - 'id' => $id, - 'spam_tag_level' => Request::post('spam_tag_level', Rspamd::DEFAULT_MARK_LVL), - 'spam_kill_level' => Request::post('spam_kill_level', Rspamd::DEFAULT_REJECT_LVL) - ])->update(); + Emails::getLocal($userinfo, Request::postAll())->update(); } catch (Exception $e) { Response::dynamicError($e->getMessage()); } @@ -291,88 +287,12 @@ $email_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_edit.php'; - if (Settings::Get('catchall.catchall_enabled') != '1') { - unset($email_edit_data['emails_edit']['sections']['section_a']['fields']['mail_catchall']); - } - UI::view('user/form.html.twig', [ 'formaction' => $linker->getLink(['section' => 'email']), 'formdata' => $email_edit_data['emails_edit'], 'editid' => $id ]); } - } elseif ($action == 'togglebypass' && $id != 0) { - try { - $json_result = Emails::getLocal($userinfo, [ - 'id' => $id - ])->get(); - } catch (Exception $e) { - Response::dynamicError($e->getMessage()); - } - $result = json_decode($json_result, true)['data']; - - try { - Emails::getLocal($userinfo, [ - 'id' => $id, - 'bypass_spam' => ($result['bypass_spam'] == '1' ? 0 : 1) - ])->update(); - } catch (Exception $e) { - Response::dynamicError($e->getMessage()); - } - Response::redirectTo($filename, [ - 'page' => $page, - 'domainid' => $email_domainid, - 'action' => 'edit', - 'id' => $id, - ]); - } elseif ($action == 'togglegreylist' && $id != 0) { - try { - $json_result = Emails::getLocal($userinfo, [ - 'id' => $id - ])->get(); - } catch (Exception $e) { - Response::dynamicError($e->getMessage()); - } - $result = json_decode($json_result, true)['data']; - - try { - Emails::getLocal($userinfo, [ - 'id' => $id, - 'policy_greylist' => ($result['policy_greylist'] == '1' ? 0 : 1) - ])->update(); - } catch (Exception $e) { - Response::dynamicError($e->getMessage()); - } - Response::redirectTo($filename, [ - 'page' => $page, - 'domainid' => $email_domainid, - 'action' => 'edit', - 'id' => $id, - ]); - } elseif ($action == 'togglecatchall' && $id != 0) { - try { - $json_result = Emails::getLocal($userinfo, [ - 'id' => $id - ])->get(); - } catch (Exception $e) { - Response::dynamicError($e->getMessage()); - } - $result = json_decode($json_result, true)['data']; - - try { - Emails::getLocal($userinfo, [ - 'id' => $id, - 'iscatchall' => ($result['iscatchall'] == '1' ? 0 : 1) - ])->update(); - } catch (Exception $e) { - Response::dynamicError($e->getMessage()); - } - Response::redirectTo($filename, [ - 'page' => $page, - 'domainid' => $email_domainid, - 'action' => 'edit', - 'id' => $id, - ]); } } elseif ($page == 'accounts') { $email_domainid = Request::any('domainid', 0); diff --git a/install/froxlor.sql.php b/install/froxlor.sql.php index 21add8c97c..f3d4b114ca 100644 --- a/install/froxlor.sql.php +++ b/install/froxlor.sql.php @@ -495,7 +495,6 @@ opcache.use_cwd opcache.fast_shutdown'), ('phpfpm', 'ini_admin_values', 'cgi.redirect_status_env -date.timezone disable_classes disable_functions error_log diff --git a/lib/Froxlor/Api/Commands/Customers.php b/lib/Froxlor/Api/Commands/Customers.php index ccbef644cf..f0492ed22c 100644 --- a/lib/Froxlor/Api/Commands/Customers.php +++ b/lib/Froxlor/Api/Commands/Customers.php @@ -738,11 +738,12 @@ public function add() 'adminid' => $this->getUserDetail('adminid'), 'docroot' => $documentroot, 'phpenabled' => $phpenabled, - 'openbasedir' => '1' + 'openbasedir' => '1', + 'is_stdsubdomain' => 1 ]; $domainid = -1; try { - $std_domain = $this->apiCall('Domains.add', $ins_data); + $std_domain = $this->apiCall('Domains.add', $ins_data, true); $domainid = $std_domain['id']; } catch (Exception $e) { $this->logger()->logAction(FroxlorLogger::ADM_ACTION, LOG_ERR, "[API] Unable to add standard-subdomain: " . $e->getMessage()); diff --git a/lib/Froxlor/Api/Commands/Domains.php b/lib/Froxlor/Api/Commands/Domains.php index 2dfbfb9441..0ed0fbc9f3 100644 --- a/lib/Froxlor/Api/Commands/Domains.php +++ b/lib/Froxlor/Api/Commands/Domains.php @@ -274,7 +274,8 @@ public function listingCount() * $override_tls is true * @param string $description * optional custom description (currently not used/shown in the frontend), default empty - * + * @param bool $is_stdsubdomain (internally) + * optional whether this is a standard subdomain for a customer which is being added so no usage is decreased * @access admin * @return string json-encoded array * @throws Exception @@ -282,7 +283,8 @@ public function listingCount() public function add() { if ($this->isAdmin()) { - if ($this->getUserDetail('domains_used') < $this->getUserDetail('domains') || $this->getUserDetail('domains') == '-1') { + $is_stdsubdomain = $this->isInternal() ? $this->getBoolParam('is_stdsubdomain', true, 0) : false; + if ($is_stdsubdomain || $this->getUserDetail('domains_used') < $this->getUserDetail('domains') || $this->getUserDetail('domains') == '-1') { // parameters $p_domain = $this->getParam('domain'); @@ -795,12 +797,15 @@ public function add() $ins_data['id'] = $domainid; unset($ins_data); - $upd_stmt = Database::prepare(" - UPDATE `" . TABLE_PANEL_ADMINS . "` SET `domains_used` = `domains_used` + 1 - WHERE `adminid` = :adminid"); - Database::pexecute($upd_stmt, [ - 'adminid' => $adminid - ], true, true); + if (!$is_stdsubdomain) { + $upd_stmt = Database::prepare(" + UPDATE `" . TABLE_PANEL_ADMINS . "` SET `domains_used` = `domains_used` + 1 + WHERE `adminid` = :adminid + "); + Database::pexecute($upd_stmt, [ + 'adminid' => $adminid + ], true, true); + } $ins_stmt = Database::prepare(" INSERT INTO `" . TABLE_DOMAINTOIP . "` SET diff --git a/lib/Froxlor/Cli/ConfigServices.php b/lib/Froxlor/Cli/ConfigServices.php index b37365a599..54d5c455a7 100644 --- a/lib/Froxlor/Cli/ConfigServices.php +++ b/lib/Froxlor/Cli/ConfigServices.php @@ -217,6 +217,10 @@ private function createConfig(OutputInterface $output, SymfonyStyle $io): int $_daemons_config['distro'] = $io->choice('Choose distribution', $valid_dists, $os_default); // go through all services and let user check whether to include it or not + if (empty($_daemons_config['distro']) || !file_exists($config_dir . '/' . $_daemons_config['distro']. ".xml")) { + $output->writeln('Empty or non-existing distribution given.'); + return self::INVALID; + } $configfiles = new ConfigParser($config_dir . '/' . $_daemons_config['distro'] . ".xml"); $services = $configfiles->getServices(); @@ -352,8 +356,13 @@ private function applyConfig(InputInterface $input, OutputInterface $output, Sym } if (!empty($decoded_config)) { + $config_dir = Froxlor::getInstallDir() . 'lib/configfiles/'; - $configfiles = new ConfigParser($config_dir . '/' . $decoded_config['distro'] . ".xml"); + if (empty($decoded_config['distro']) || !file_exists($config_dir . '/' . $decoded_config['distro']. ".xml")) { + $output->writeln('Empty or non-existing distribution given. Please login with an admin, go to "System -> Configuration" and select your correct distribution in the top-right corner or specify valid distribution name for "distro" parameter.'); + return self::INVALID; + } + $configfiles = new ConfigParser($config_dir . '/' . $decoded_config['distro']. ".xml"); $services = $configfiles->getServices(); $replace_arr = $this->getReplacerArray(); diff --git a/lib/Froxlor/Cron/Mail/Rspamd.php b/lib/Froxlor/Cron/Mail/Rspamd.php index ece477663f..624e91ddd5 100644 --- a/lib/Froxlor/Cron/Mail/Rspamd.php +++ b/lib/Froxlor/Cron/Mail/Rspamd.php @@ -185,7 +185,7 @@ private function generateEmailAddrConfig(array $email): void $this->frx_settings_file .= ' apply {' . "\n"; $this->frx_settings_file .= ' actions {' . "\n"; $this->frx_settings_file .= ' "add header" = ' . $email['spam_tag_level'] . ';' . "\n"; - $this->frx_settings_file .= ' rewrite_subject = ' . $email['spam_tag_level'] . ';' . "\n"; + $this->frx_settings_file .= ' rewrite_subject = ' . ($email['spam_tag_level'] + 0.01) . ';' . "\n"; $this->frx_settings_file .= ' reject = ' . $email['spam_kill_level'] . ';' . "\n"; if ($type == 'rcpt' && (int)$email['policy_greylist'] == 0) { $this->frx_settings_file .= ' greylist = null;' . "\n"; diff --git a/lib/formfields/customer/email/formfield.emails_edit.php b/lib/formfields/customer/email/formfield.emails_edit.php index 3068054392..a56f14a1a9 100644 --- a/lib/formfields/customer/email/formfield.emails_edit.php +++ b/lib/formfields/customer/email/formfield.emails_edit.php @@ -90,17 +90,11 @@ ] ], 'mail_catchall' => [ + 'visible' => Settings::Get('catchall.catchall_enabled') == '1', 'label' => lng('emails.catchall'), - 'type' => 'label', - 'value' => ((int)$result['iscatchall'] == 0 ? lng('panel.no') : lng('panel.yes')), - 'next_to' => [ - 'add_link' => [ - 'type' => 'link', - 'href' => $filename . '?page=' . $page . '&domainid=' . $result['domainid'] . '&action=togglecatchall&id=' . $result['id'], - 'label' => ' ' . lng('panel.toggle'), - 'classes' => 'btn btn-sm btn-secondary' - ] - ] + 'type' => 'checkbox', + 'value' => '1', + 'checked' => (int)$result['iscatchall'], ], 'spam_tag_level' => [ 'visible' => Settings::Get('antispam.activated') == '1', @@ -119,30 +113,16 @@ 'bypass_spam' => [ 'visible' => Settings::Get('antispam.activated') == '1', 'label' => lng('antispam.bypass_spam'), - 'type' => 'label', - 'value' => ((int)$result['bypass_spam'] == 0 ? lng('panel.no') : lng('panel.yes')), - 'next_to' => [ - 'add_link' => [ - 'type' => 'link', - 'href' => $filename . '?page=' . $page . '&domainid=' . $result['domainid'] . '&action=togglebypass&id=' . $result['id'], - 'label' => ' ' . lng('panel.toggle'), - 'classes' => 'btn btn-sm btn-secondary' - ] - ] + 'type' => 'checkbox', + 'value' => '1', + 'checked' => (int)$result['bypass_spam'], ], 'policy_greylist' => [ 'visible' => Settings::Get('antispam.activated') == '1', 'label' => lng('antispam.policy_greylist'), - 'type' => 'label', - 'value' => ((int)$result['policy_greylist'] == 0 ? lng('panel.no') : lng('panel.yes')), - 'next_to' => [ - 'add_link' => [ - 'type' => 'link', - 'href' => $filename . '?page=' . $page . '&domainid=' . $result['domainid'] . '&action=togglegreylist&id=' . $result['id'], - 'label' => ' ' . lng('panel.toggle'), - 'classes' => 'btn btn-sm btn-secondary' - ] - ] + 'type' => 'checkbox', + 'value' => '1', + 'checked' => (int)$result['policy_greylist'], ], 'mail_fwds' => [ 'label' => lng('emails.forwarders') . ' (' . $forwarders_count . ')',