diff --git a/config/email.php b/config/email.php new file mode 100644 index 000000000..a9c819d5d --- /dev/null +++ b/config/email.php @@ -0,0 +1,20 @@ + true, + 'smtp' => [ + 'enabled' => false, // send email via external SMTP server + 'host' => '', // SMTP server host + 'port' => 25, // SMTP server port + 'username' => '', // SMTP username (if server requires it) + 'password' => '', // SMTP password (if server requires it) + ], + 'ssl_type' => '', // SMTP ssl type (ssl or tls) +]; diff --git a/library/TorrentPier/TorrentPier/Legacy/Emailer.php b/library/TorrentPier/TorrentPier/Legacy/Emailer.php index 37e1278a0..60534af2a 100644 --- a/library/TorrentPier/TorrentPier/Legacy/Emailer.php +++ b/library/TorrentPier/TorrentPier/Legacy/Emailer.php @@ -164,7 +164,7 @@ class Emailer { global $bb_cfg, $lang, $userdata; - if (!$bb_cfg['emailer']['enabled']) { + if (!config('email.enabled')) { return false; } @@ -180,25 +180,25 @@ class Emailer $this->encoding = config('language.charset'); /** Prepare message */ - if ($bb_cfg['emailer']['smtp']['enabled']) { - if (!empty($bb_cfg['emailer']['smtp']['host'])) { - if (empty($bb_cfg['emailer']['ssl_type'])) { + if (config('email.smtp.enabled')) { + if (!empty(config('email.smtp.host'))) { + if (empty(config('email.ssl_type'))) { /** @var Swift_SmtpTransport $transport external SMTP without ssl */ $transport = (new Swift_SmtpTransport( - $bb_cfg['emailer']['smtp']['host'], - $bb_cfg['emailer']['smtp']['port'] + config('email.smtp.host'), + config('email.smtp.port') )) - ->setUsername($bb_cfg['emailer']['smtp']['username']) - ->setPassword($bb_cfg['emailer']['smtp']['password']); + ->setUsername(config('email.smtp.username')) + ->setPassword(config('email.smtp.password')); } else { /** @var Swift_SmtpTransport $transport external SMTP with ssl */ $transport = (new Swift_SmtpTransport( - $bb_cfg['emailer']['smtp']['host'], - $bb_cfg['emailer']['smtp']['port'], - $bb_cfg['emailer']['ssl_type'] + config('email.smtp.host'), + config('email.smtp.port'), + config('email.ssl_type') )) - ->setUsername($bb_cfg['emailer']['smtp']['username']) - ->setPassword($bb_cfg['emailer']['smtp']['password']); + ->setUsername(config('email.smtp.username')) + ->setPassword(config('email.smtp.password')); } } else { /** @var Swift_SmtpTransport $transport local SMTP */ diff --git a/library/config.php b/library/config.php index 4eb64c5b3..08a5c3cdc 100644 --- a/library/config.php +++ b/library/config.php @@ -183,18 +183,6 @@ $bb_cfg['new_user_reg_restricted'] = false; // Ограничить регист $bb_cfg['reg_email_activation'] = true; // Требовать активацию учетной записи по email // Email -$bb_cfg['emailer'] = [ - 'enabled' => true, - 'smtp' => [ - 'enabled' => false, // send email via external SMTP server - 'host' => '', // SMTP server host - 'port' => 25, // SMTP server port - 'username' => '', // SMTP username (if server requires it) - 'password' => '', // SMTP password (if server requires it) - ], - 'ssl_type' => '', // SMTP ssl type (ssl or tls) -]; - $bb_cfg['board_email'] = "noreply@$domain_name"; // admin email address $bb_cfg['board_email_form'] = false; // can users send email to each other via board $bb_cfg['board_email_sig'] = ''; // this text will be attached to all emails the board sends @@ -395,23 +383,6 @@ $bb_cfg['nofollow'] = [ 'allowed_url' => [$domain_name], // 'allowed.site', 'www.allowed.site' ]; -// Page settings -$bb_cfg['page'] = [ - 'show_torhelp' => [ - #BB_SCRIPT => true - 'index' => true, - 'tracker' => true, - ], - 'show_sidebar1' => [ - #BB_SCRIPT => true - 'index' => true, - ], - 'show_sidebar2' => [ - #BB_SCRIPT => true - 'index' => true, - ] -]; - // Tracker settings $bb_cfg['tracker'] = [ 'autoclean' => true, diff --git a/library/includes/page_header.php b/library/includes/page_header.php index d8c62e94f..82b6729b6 100644 --- a/library/includes/page_header.php +++ b/library/includes/page_header.php @@ -166,8 +166,8 @@ $template->assign_vars(array( 'U_TERMS' => $bb_cfg['terms_and_conditions_url'], 'U_TRACKER' => "tracker.php", - 'SHOW_SIDEBAR1' => !empty($bb_cfg['page']['show_sidebar1'][BB_SCRIPT]) || $bb_cfg['show_sidebar1_on_every_page'], - 'SHOW_SIDEBAR2' => !empty($bb_cfg['page']['show_sidebar2'][BB_SCRIPT]) || $bb_cfg['show_sidebar2_on_every_page'], + 'SHOW_SIDEBAR1' => !empty(config('page.show_sidebar1.' . BB_SCRIPT)) || $bb_cfg['show_sidebar1_on_every_page'], + 'SHOW_SIDEBAR2' => !empty(config('page.show_sidebar2.' . BB_SCRIPT)) || $bb_cfg['show_sidebar2_on_every_page'], 'HTML_AGREEMENT' => LANG_DIR . 'html/user_agreement.html', 'HTML_COPYRIGHT' => LANG_DIR . 'html/copyright_holders.html', @@ -209,7 +209,7 @@ $template->assign_vars(array( 'U_WATCHED_TOPICS' => "profile.php?mode=watch", )); -if (!empty($bb_cfg['page']['show_torhelp'][BB_SCRIPT]) && !empty($userdata['torhelp'])) { +if (!empty(config('page.show_torhelp.' . BB_SCRIPT)) && !empty($userdata['torhelp'])) { $ignore_time = !empty($_COOKIE['torhelp']) ? (int)$_COOKIE['torhelp'] : 0; if (TIMENOW > $ignore_time) { diff --git a/library/includes/ucp/register.php b/library/includes/ucp/register.php index 7a7902f47..2d724f1c4 100644 --- a/library/includes/ucp/register.php +++ b/library/includes/ucp/register.php @@ -60,7 +60,7 @@ switch ($mode) { } } // Отключение регистрации - if ($bb_cfg['new_user_reg_disabled'] || ($bb_cfg['reg_email_activation'] && !$bb_cfg['emailer']['enabled'])) { + if ($bb_cfg['new_user_reg_disabled'] || ($bb_cfg['reg_email_activation'] && !config('email.enabled'))) { bb_die($lang['NEW_USER_REG_DISABLED']); } // Ограничение по времени elseif ($bb_cfg['new_user_reg_restricted']) { diff --git a/library/includes/ucp/sendpasswd.php b/library/includes/ucp/sendpasswd.php index 15d797ed1..90442df64 100644 --- a/library/includes/ucp/sendpasswd.php +++ b/library/includes/ucp/sendpasswd.php @@ -13,7 +13,7 @@ if (!defined('BB_ROOT')) { set_die_append_msg(); -if (!$bb_cfg['emailer']['enabled']) { +if (!config('email.enabled')) { bb_die($lang['EMAILER_DISABLED']); } diff --git a/library/language/en/html/sidebar2.html b/library/language/en/html/sidebar2.html index 08a4bdf20..3ee223024 100644 --- a/library/language/en/html/sidebar2.html +++ b/library/language/en/html/sidebar2.html @@ -7,5 +7,5 @@
  • style/templates/default/page_footer.tpl

  • - To disable this sidebar, set the variable $bb_cfg['page']['show_sidebar2'] in file config.php to false. + To disable this sidebar, set the variable 'show_sidebar2' in file config/page.php to false. diff --git a/library/language/source/html/sidebar2.html b/library/language/source/html/sidebar2.html index 08a4bdf20..3ee223024 100644 --- a/library/language/source/html/sidebar2.html +++ b/library/language/source/html/sidebar2.html @@ -7,5 +7,5 @@
  • style/templates/default/page_footer.tpl

  • - To disable this sidebar, set the variable $bb_cfg['page']['show_sidebar2'] in file config.php to false. + To disable this sidebar, set the variable 'show_sidebar2' in file config/page.php to false.