diff options
40 files changed, 1745 insertions, 397 deletions
diff --git a/phpBB/adm/style/acp_contact.html b/phpBB/adm/style/acp_contact.html new file mode 100644 index 0000000000..828fd4b659 --- /dev/null +++ b/phpBB/adm/style/acp_contact.html @@ -0,0 +1,76 @@ +<!-- INCLUDE overall_header.html --> + +<script type="text/javascript"> +// <![CDATA[ + + var form_name = 'acp_contact'; + var text_name = 'contact_admin_info'; + var load_draft = false; + var upload = false; + var imageTag = false; + +// ]]> +</script> + +<a id="maincontent"></a> + +<h1>{L_ACP_CONTACT_SETTINGS}</h1> + +<p>{L_ACP_CONTACT_SETTINGS_EXPLAIN}</p> + +<form id="acp_contact" method="post" action="{U_ACTION}"> + <fieldset> + <legend>{L_GENERAL_OPTIONS}</legend> + <dl> + <dt><label for="contact_admin_form_enable">{L_CONTACT_US_ENABLE}{L_COLON}</label><br /><span>{L_CONTACT_US_ENABLE_EXPLAIN}</span></dt> + <dd> + <label><input type="radio" class="radio" id="contact_admin_form_enable" name="contact_admin_form_enable" value="1"<!-- IF CONTACT_ENABLED --> checked="checked"<!-- ENDIF --> /> {L_ENABLED}</label> + <label><input type="radio" class="radio" name="contact_admin_form_enable" value="0"<!-- IF not CONTACT_ENABLED --> checked="checked"<!-- ENDIF --> /> {L_DISABLED}</label> + </dd> + </dl> + </fieldset> + + <!-- IF CONTACT_US_INFO_PREVIEW --> + <fieldset> + <legend>{L_CONTACT_US_INFO_PREVIEW}</legend> + <p>{CONTACT_US_INFO_PREVIEW}</p> + </fieldset> + <!-- ENDIF --> + + <fieldset> + <legend>{L_CONTACT_US_INFO}</legend> + <p>{L_CONTACT_US_INFO_EXPLAIN}</p> + + <!-- INCLUDE acp_posting_buttons.html --> + + <dl class="responsive-columns"> + <dt style="width: 90px;" id="color_palette_placeholder" data-orientation="v" data-height="12" data-width="15" data-bbcode="true"> + </dt> + + <dd style="margin-{S_CONTENT_FLOW_BEGIN}: 90px;"> + <textarea name="contact_admin_info" rows="10" cols="60" style="width: 95%;" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onfocus="initInsertions();" data-bbcode="true">{CONTACT_US_INFO}</textarea> + </dd> + + <dd style="margin-{S_CONTENT_FLOW_BEGIN}: 90px; margin-top: 5px;"> + <!-- IF S_BBCODE_ALLOWED --> + <label><input type="checkbox" class="radio" name="disable_bbcode"<!-- IF S_BBCODE_DISABLE_CHECKED --> checked="checked"<!-- ENDIF --> /> {L_DISABLE_BBCODE}</label> + <!-- ENDIF --> + <!-- IF S_SMILIES_ALLOWED --> + <label><input type="checkbox" class="radio" name="disable_smilies"<!-- IF S_SMILIES_DISABLE_CHECKED --> checked="checked"<!-- ENDIF --> /> {L_DISABLE_SMILIES}</label> + <!-- ENDIF --> + <!-- IF S_LINKS_ALLOWED --> + <label><input type="checkbox" class="radio" name="disable_magic_url"<!-- IF S_MAGIC_URL_DISABLE_CHECKED --> checked="checked"<!-- ENDIF --> /> {L_DISABLE_MAGIC_URL}</label> + <!-- ENDIF --> + </dd> + <dd style="margin-{S_CONTENT_FLOW_BEGIN}: 90px; margin-top: 10px;"><strong>{L_OPTIONS}{L_COLON} </strong>{BBCODE_STATUS} :: {IMG_STATUS} :: {FLASH_STATUS} :: {URL_STATUS} :: {SMILIES_STATUS}</dd> + </dl> + </fieldset> + + <fieldset class="submit-buttons"> + <input class="button1" type="submit" id="submit" name="submit" value="{L_SUBMIT}" /> + <input class="button2" type="submit" name="preview" value="{L_PREVIEW}" /> + {S_FORM_TOKEN} + </fieldset> +</form> + +<!-- INCLUDE overall_footer.html --> diff --git a/phpBB/adm/style/acp_posting_buttons.html b/phpBB/adm/style/acp_posting_buttons.html new file mode 100644 index 0000000000..70b6259689 --- /dev/null +++ b/phpBB/adm/style/acp_posting_buttons.html @@ -0,0 +1,70 @@ +<script type="text/javascript"> +// <![CDATA[ + + // Define the bbCode tags + var bbcode = new Array(); + var bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','[/code]','[list]','[/list]','[list=]','[/list]','[img]','[/img]','[url]','[/url]','[flash=]', '[/flash]','[size=]','[/size]'<!-- BEGIN custom_tags -->, {custom_tags.BBCODE_NAME}<!-- END custom_tags -->); + + // Helpline messages + var help_line = { + b: '{LA_BBCODE_B_HELP}', + i: '{LA_BBCODE_I_HELP}', + u: '{LA_BBCODE_U_HELP}', + q: '{LA_BBCODE_Q_HELP}', + c: '{LA_BBCODE_C_HELP}', + l: '{LA_BBCODE_L_HELP}', + o: '{LA_BBCODE_O_HELP}', + p: '{LA_BBCODE_P_HELP}', + w: '{LA_BBCODE_W_HELP}', + a: '{LA_BBCODE_A_HELP}', + s: '{LA_BBCODE_S_HELP}', + f: '{LA_BBCODE_F_HELP}', + y: '{LA_BBCODE_Y_HELP}', + d: '{LA_BBCODE_D_HELP}' + <!-- BEGIN custom_tags --> + ,cb_{custom_tags.BBCODE_ID}{L_COLON} '{custom_tags.A_BBCODE_HELPLINE}' + <!-- END custom_tags --> + } + +// ]]> +</script> + +<!-- INCLUDEJS {T_ASSETS_PATH}/javascript/editor.js --> + +<!-- EVENT acp_posting_buttons_before --> +<div id="format-buttons"> + <input type="button" class="button2" accesskey="b" name="addbbcode0" value=" B " style="font-weight:bold; width: 30px" onclick="bbstyle(0)" title="{L_BBCODE_B_HELP}" /> + <input type="button" class="button2" accesskey="i" name="addbbcode2" value=" i " style="font-style:italic; width: 30px" onclick="bbstyle(2)" title="{L_BBCODE_I_HELP}" /> + <input type="button" class="button2" accesskey="u" name="addbbcode4" value=" u " style="text-decoration: underline; width: 30px" onclick="bbstyle(4)" title="{L_BBCODE_U_HELP}" /> + <!-- IF S_BBCODE_QUOTE --> + <input type="button" class="button2" accesskey="q" name="addbbcode6" value="Quote" style="width: 50px" onclick="bbstyle(6)" title="{L_BBCODE_Q_HELP}" /> + <!-- ENDIF --> + <input type="button" class="button2" accesskey="c" name="addbbcode8" value="Code" style="width: 40px" onclick="bbstyle(8)" title="{L_BBCODE_C_HELP}" /> + <input type="button" class="button2" accesskey="l" name="addbbcode10" value="List" style="width: 40px" onclick="bbstyle(10)" title="{L_BBCODE_L_HELP}" /> + <input type="button" class="button2" accesskey="o" name="addbbcode12" value="List=" style="width: 40px" onclick="bbstyle(12)" title="{L_BBCODE_O_HELP}" /> + <input type="button" class="button2" accesskey="y" name="addlistitem" value="[*]" style="width: 40px" onclick="bbstyle(-1)" title="{L_BBCODE_LISTITEM_HELP}" /> + <!-- IF S_BBCODE_IMG --> + <input type="button" class="button2" accesskey="p" name="addbbcode14" value="Img" style="width: 40px" onclick="bbstyle(14)" title="{L_BBCODE_P_HELP}" /> + <!-- ENDIF --> + <!-- IF S_LINKS_ALLOWED --> + <input type="button" class="button2" accesskey="w" name="addbbcode16" value="URL" style="text-decoration: underline; width: 40px" onclick="bbstyle(16)" title="{L_BBCODE_W_HELP}" /> + <!-- ENDIF --> + <!-- IF S_BBCODE_FLASH --> + <input type="button" class="button2" accesskey="d" name="addbbcode18" value="Flash" onclick="bbstyle(18)" title="{L_BBCODE_D_HELP}" /> + <!-- ENDIF --> + <select name="addbbcode20" onchange="bbfontstyle('[size=' + this.form.addbbcode20.options[this.form.addbbcode20.selectedIndex].value + ']', '[/size]');this.form.addbbcode20.selectedIndex = 2;" title="{L_BBCODE_F_HELP}"> + <option value="50">{L_FONT_TINY}</option> + <option value="85">{L_FONT_SMALL}</option> + <option value="100" selected="selected">{L_FONT_NORMAL}</option> + <!-- IF not MAX_FONT_SIZE or MAX_FONT_SIZE >= 150 --> + <option value="150">{L_FONT_LARGE}</option> + <!-- IF not MAX_FONT_SIZE or MAX_FONT_SIZE >= 200 --> + <option value="200">{L_FONT_HUGE}</option> + <!-- ENDIF --> + <!-- ENDIF --> + </select> + <!-- BEGIN custom_tags --> + <input type="button" class="button2" name="addbbcode{custom_tags.BBCODE_ID}" value="{custom_tags.BBCODE_TAG}" onclick="bbstyle({custom_tags.BBCODE_ID})" title="{custom_tags.BBCODE_HELPLINE}" /> + <!-- END custom_tags --> +</div> +<!-- EVENT acp_posting_buttons_after --> diff --git a/phpBB/adm/style/acp_users_signature.html b/phpBB/adm/style/acp_users_signature.html index 5b5c3ecf7f..c7ec5cc0eb 100644 --- a/phpBB/adm/style/acp_users_signature.html +++ b/phpBB/adm/style/acp_users_signature.html @@ -5,36 +5,10 @@ var text_name = 'signature'; var load_draft = false; var upload = false; - - // Define the bbCode tags - var bbcode = new Array(); - var bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','[/code]','[list]','[/list]','[list=]','[/list]','[img]','[/img]','[url]','[/url]','[flash=]', '[/flash]','[size=]','[/size]'<!-- BEGIN custom_tags -->, {custom_tags.BBCODE_NAME}<!-- END custom_tags -->); var imageTag = false; - // Helpline messages - var help_line = { - b: '{LA_BBCODE_B_HELP}', - i: '{LA_BBCODE_I_HELP}', - u: '{LA_BBCODE_U_HELP}', - q: '{LA_BBCODE_Q_HELP}', - c: '{LA_BBCODE_C_HELP}', - l: '{LA_BBCODE_L_HELP}', - o: '{LA_BBCODE_O_HELP}', - p: '{LA_BBCODE_P_HELP}', - w: '{LA_BBCODE_W_HELP}', - a: '{LA_BBCODE_A_HELP}', - s: '{LA_BBCODE_S_HELP}', - f: '{LA_BBCODE_F_HELP}', - y: '{LA_BBCODE_Y_HELP}', - d: '{LA_BBCODE_D_HELP}' - <!-- BEGIN custom_tags --> - ,cb_{custom_tags.BBCODE_ID}{L_COLON} '{custom_tags.A_BBCODE_HELPLINE}' - <!-- END custom_tags --> - } - // ]]> </script> -<!-- INCLUDEJS {T_ASSETS_PATH}/javascript/editor.js --> <form id="user_signature" method="post" action="{U_ACTION}"> @@ -49,43 +23,7 @@ <legend>{L_SIGNATURE}</legend> <p>{L_SIGNATURE_EXPLAIN}</p> - <!-- EVENT acp_users_signature_editor_buttons_before --> - <div id="format-buttons"> - <input type="button" class="button2" accesskey="b" name="addbbcode0" value=" B " style="font-weight:bold; width: 30px" onclick="bbstyle(0)" title="{L_BBCODE_B_HELP}" /> - <input type="button" class="button2" accesskey="i" name="addbbcode2" value=" i " style="font-style:italic; width: 30px" onclick="bbstyle(2)" title="{L_BBCODE_I_HELP}" /> - <input type="button" class="button2" accesskey="u" name="addbbcode4" value=" u " style="text-decoration: underline; width: 30px" onclick="bbstyle(4)" title="{L_BBCODE_U_HELP}" /> - <!-- IF S_BBCODE_QUOTE --> - <input type="button" class="button2" accesskey="q" name="addbbcode6" value="Quote" style="width: 50px" onclick="bbstyle(6)" title="{L_BBCODE_Q_HELP}" /> - <!-- ENDIF --> - <input type="button" class="button2" accesskey="c" name="addbbcode8" value="Code" style="width: 40px" onclick="bbstyle(8)" title="{L_BBCODE_C_HELP}" /> - <input type="button" class="button2" accesskey="l" name="addbbcode10" value="List" style="width: 40px" onclick="bbstyle(10)" title="{L_BBCODE_L_HELP}" /> - <input type="button" class="button2" accesskey="o" name="addbbcode12" value="List=" style="width: 40px" onclick="bbstyle(12)" title="{L_BBCODE_O_HELP}" /> - <input type="button" class="button2" accesskey="y" name="addlistitem" value="[*]" style="width: 40px" onclick="bbstyle(-1)" title="{L_BBCODE_LISTITEM_HELP}" /> - <!-- IF S_BBCODE_IMG --> - <input type="button" class="button2" accesskey="p" name="addbbcode14" value="Img" style="width: 40px" onclick="bbstyle(14)" title="{L_BBCODE_P_HELP}" /> - <!-- ENDIF --> - <!-- IF S_LINKS_ALLOWED --> - <input type="button" class="button2" accesskey="w" name="addbbcode16" value="URL" style="text-decoration: underline; width: 40px" onclick="bbstyle(16)" title="{L_BBCODE_W_HELP}" /> - <!-- ENDIF --> - <!-- IF S_BBCODE_FLASH --> - <input type="button" class="button2" accesskey="d" name="addbbcode18" value="Flash" onclick="bbstyle(18)" title="{L_BBCODE_D_HELP}" /> - <!-- ENDIF --> - <select name="addbbcode20" onchange="bbfontstyle('[size=' + this.form.addbbcode20.options[this.form.addbbcode20.selectedIndex].value + ']', '[/size]');this.form.addbbcode20.selectedIndex = 2;" title="{L_BBCODE_F_HELP}"> - <option value="50">{L_FONT_TINY}</option> - <option value="85">{L_FONT_SMALL}</option> - <option value="100" selected="selected">{L_FONT_NORMAL}</option> - <!-- IF not MAX_FONT_SIZE or MAX_FONT_SIZE >= 150 --> - <option value="150">{L_FONT_LARGE}</option> - <!-- IF not MAX_FONT_SIZE or MAX_FONT_SIZE >= 200 --> - <option value="200">{L_FONT_HUGE}</option> - <!-- ENDIF --> - <!-- ENDIF --> - </select> - <!-- BEGIN custom_tags --> - <input type="button" class="button2" name="addbbcode{custom_tags.BBCODE_ID}" value="{custom_tags.BBCODE_TAG}" onclick="bbstyle({custom_tags.BBCODE_ID})" title="{custom_tags.BBCODE_HELPLINE}" /> - <!-- END custom_tags --> - </div> - <!-- EVENT acp_users_signature_editor_buttons_after --> + <!-- INCLUDE acp_posting_buttons.html --> <dl class="responsive-columns"> <dt style="width: 90px;" id="color_palette_placeholder" data-orientation="v" data-height="12" data-width="15" data-bbcode="true"> diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 3bd9182924..3743daa075 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -239,6 +239,38 @@ services: - %core.php_ext% - %tables.log% + message.form.admin: + class: phpbb\message\admin_form + arguments: + - @auth + - @config + - @config_text + - @dbal.conn + - @user + - %core.root_path% + - %core.php_ext% + + message.form.topic: + class: phpbb\message\topic_form + arguments: + - @auth + - @config + - @config_text + - @dbal.conn + - @user + - %core.root_path% + - %core.php_ext% + + message.form.user: + class: phpbb\message\user_form + arguments: + - @auth + - @config + - @dbal.conn + - @user + - %core.root_path% + - %core.php_ext% + notification_manager: class: phpbb\notification\manager arguments: diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 4dc55540f3..44a7824901 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -64,6 +64,20 @@ acp_overall_header_head_append * Since: 3.1.0-a1 * Purpose: Add assets within the `<head>` tags in the ACP +acp_posting_buttons_after +=== +* Locations: + + adm/style/acp_posting_buttons.html +* Since: 3.1.0-b4 +* Purpose: Add content after BBCode posting buttons in the ACP + +acp_posting_buttons_before +=== +* Locations: + + adm/style/acp_posting_buttons.html +* Since: 3.1.0-b4 +* Purpose: Add content before BBCode posting buttons in the ACP + acp_simple_footer_after === * Location: adm/style/simple_footer.html @@ -136,20 +150,6 @@ acp_users_prefs_view_prepend * Since: 3.1.0-b3 * Purpose: Add user options fieldset to the top of ACP users view prefs settings -acp_users_signature_editor_buttons_after -=== -* Locations: - + adm/style/acp_users_signature.html -* Since: 3.1.0-a3 -* Purpose: Add content after BBCode posting buttons in the ACP user signature - -acp_users_signature_editor_buttons_before -=== -* Locations: - + adm/style/acp_users_signature.html -* Since: 3.1.0-a3 -* Purpose: Add content before BBCode posting buttons in the ACP user signature - forumlist_body_category_header_after === * Locations: diff --git a/phpBB/includes/acp/acp_contact.php b/phpBB/includes/acp/acp_contact.php new file mode 100644 index 0000000000..13d38d9f29 --- /dev/null +++ b/phpBB/includes/acp/acp_contact.php @@ -0,0 +1,129 @@ +<?php +/** +* +* @package acp +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +*/ + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +/** +* @package acp +*/ +class acp_contact +{ + public $u_action; + + public function main($id, $mode) + { + global $user, $request, $template; + global $config, $phpbb_root_path, $phpEx, $phpbb_container; + + $user->add_lang(array('acp/board', 'posting')); + + $this->tpl_name = 'acp_contact'; + $this->page_title = 'ACP_CONTACT_SETTINGS'; + $form_name = 'acp_contact'; + add_form_key($form_name); + $error = ''; + + if (!function_exists('display_custom_bbcodes')) + { + include($phpbb_root_path . 'includes/functions_display.' . $phpEx); + } + if (!class_exists('parse_message')) + { + include($phpbb_root_path . 'includes/message_parser.' . $phpEx); + } + + $config_text = $phpbb_container->get('config_text'); + + $contact_admin_data = $config_text->get_array(array( + 'contact_admin_info', + 'contact_admin_info_uid', + 'contact_admin_info_bitfield', + 'contact_admin_info_flags', + )); + + $contact_admin_info = $contact_admin_data['contact_admin_info']; + $contact_admin_info_uid = $contact_admin_data['contact_admin_info_uid']; + $contact_admin_info_bitfield= $contact_admin_data['contact_admin_info_bitfield']; + $contact_admin_info_flags = $contact_admin_data['contact_admin_info_flags']; + + if ($request->is_set_post('submit') || $request->is_set_post('preview')) + { + if (!check_form_key($form_name)) + { + $error = $user->lang('FORM_INVALID'); + } + + $contact_admin_info = $request->variable('contact_admin_info', '', true); + + generate_text_for_storage( + $contact_admin_info, + $contact_admin_info_uid, + $contact_admin_info_bitfield, + $contact_admin_info_flags, + !$request->variable('disable_bbcode', false), + !$request->variable('disable_magic_url', false), + !$request->variable('disable_smilies', false) + ); + + if (empty($error) && $request->is_set_post('submit')) + { + $config->set('contact_admin_form_enable', $request->variable('contact_admin_form_enable', false)); + + $config_text->set_array(array( + 'contact_admin_info' => $contact_admin_info, + 'contact_admin_info_uid' => $contact_admin_info_uid, + 'contact_admin_info_bitfield' => $contact_admin_info_bitfield, + 'contact_admin_info_flags' => $contact_admin_info_flags, + )); + + trigger_error($user->lang['CONTACT_US_INFO_UPDATED'] . adm_back_link($this->u_action)); + } + } + + $contact_admin_info_preview = ''; + if ($request->is_set_post('preview')) + { + $contact_admin_info_preview = generate_text_for_display($contact_admin_info, $contact_admin_info_uid, $contact_admin_info_bitfield, $contact_admin_info_flags); + } + + $contact_admin_edit = generate_text_for_edit($contact_admin_info, $contact_admin_info_uid, $contact_admin_info_flags); + + $template->assign_vars(array( + 'ERRORS' => $error, + 'CONTACT_ENABLED' => $config['contact_admin_form_enable'], + + 'CONTACT_US_INFO' => $contact_admin_edit['text'], + 'CONTACT_US_INFO_PREVIEW' => $contact_admin_info_preview, + + 'S_BBCODE_DISABLE_CHECKED' => !$contact_admin_edit['allow_bbcode'], + 'S_SMILIES_DISABLE_CHECKED' => !$contact_admin_edit['allow_smilies'], + 'S_MAGIC_URL_DISABLE_CHECKED' => !$contact_admin_edit['allow_urls'], + + 'BBCODE_STATUS' => $user->lang('BBCODE_IS_ON', '<a href="' . append_sid("{$phpbb_root_path}faq.$phpEx", 'mode=bbcode') . '">', '</a>'), + 'SMILIES_STATUS' => $user->lang['SMILIES_ARE_ON'], + 'IMG_STATUS' => $user->lang['IMAGES_ARE_ON'], + 'FLASH_STATUS' => $user->lang['FLASH_IS_ON'], + 'URL_STATUS' => $user->lang['URL_IS_ON'], + + 'S_BBCODE_ALLOWED' => true, + 'S_SMILIES_ALLOWED' => true, + 'S_BBCODE_IMG' => true, + 'S_BBCODE_FLASH' => true, + 'S_LINKS_ALLOWED' => true, + )); + + // Assigning custom bbcodes + display_custom_bbcodes(); + } +} diff --git a/phpBB/includes/acp/acp_email.php b/phpBB/includes/acp/acp_email.php index 63bfa3ac53..fe55b36e67 100644 --- a/phpBB/includes/acp/acp_email.php +++ b/phpBB/includes/acp/acp_email.php @@ -201,7 +201,7 @@ class acp_email $messenger->set_mail_priority($priority); $messenger->assign_vars(array( - 'CONTACT_EMAIL' => $config['board_contact'], + 'CONTACT_EMAIL' => phpbb_get_board_contact($config, $phpEx), 'MESSAGE' => htmlspecialchars_decode($message)) ); diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index b653ddd13b..83ab88d48c 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -814,7 +814,7 @@ class acp_users $check_ary += array( 'email' => array( array('string', false, 6, 60), - array('email', $user_row['user_email']) + array('user_email', $user_row['user_email']), ), ); } diff --git a/phpBB/includes/acp/info/acp_contact.php b/phpBB/includes/acp/info/acp_contact.php new file mode 100644 index 0000000000..b8326f34ea --- /dev/null +++ b/phpBB/includes/acp/info/acp_contact.php @@ -0,0 +1,26 @@ +<?php +/** +* +* @package acp +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +/** +* @package module_install +*/ +class acp_contact_info +{ + public function module() + { + return array( + 'filename' => 'acp_contact', + 'title' => 'ACP_CONTACT', + 'version' => '1.0.0', + 'modes' => array( + 'contact' => array('title' => 'ACP_CONTACT_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION')), + ), + ); + } +} diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php index dde3f9d4c9..8e1e61bdb7 100644 --- a/phpBB/includes/captcha/plugins/captcha_abstract.php +++ b/phpBB/includes/captcha/plugins/captcha_abstract.php @@ -96,7 +96,8 @@ class phpbb_captcha_plugins_captcha_abstract else { $link = append_sid($phpbb_root_path . 'ucp.' . $phpEx, 'mode=confirm&confirm_id=' . $this->confirm_id . '&type=' . $this->type); - $explain = $user->lang(($this->type != CONFIRM_POST) ? 'CONFIRM_EXPLAIN' : 'POST_CONFIRM_EXPLAIN', '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">', '</a>'); + $contact_link = phpbb_get_board_contact_link($config, $phpbb_root_path, $phpEx); + $explain = $user->lang(($this->type != CONFIRM_POST) ? 'CONFIRM_EXPLAIN' : 'POST_CONFIRM_EXPLAIN', '<a href="' . $contact_link . '">', '</a>'); $template->assign_vars(array( 'CONFIRM_IMAGE_LINK' => $link, diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index 0568cb7c51..12cc49ef9b 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -150,7 +150,7 @@ class phpbb_recaptcha extends phpbb_default_captcha function get_template() { - global $config, $user, $template; + global $config, $user, $template, $phpbb_root_path, $phpEx; if ($this->is_solved()) { @@ -158,7 +158,8 @@ class phpbb_recaptcha extends phpbb_default_captcha } else { - $explain = $user->lang(($this->type != CONFIRM_POST) ? 'CONFIRM_EXPLAIN' : 'POST_CONFIRM_EXPLAIN', '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">', '</a>'); + $contact_link = phpbb_get_board_contact_link($config, $phpbb_root_path, $phpEx); + $explain = $user->lang(($this->type != CONFIRM_POST) ? 'CONFIRM_EXPLAIN' : 'POST_CONFIRM_EXPLAIN', '<a href="' . $contact_link . '">', '</a>'); $template->assign_vars(array( 'RECAPTCHA_SERVER' => $this->recaptcha_server, diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index cf18cafe90..723956de0c 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -233,6 +233,7 @@ define('BBCODES_TABLE', $table_prefix . 'bbcodes'); define('BOOKMARKS_TABLE', $table_prefix . 'bookmarks'); define('BOTS_TABLE', $table_prefix . 'bots'); define('CONFIG_TABLE', $table_prefix . 'config'); +define('CONFIG_TEXT_TABLE', $table_prefix . 'config_text'); define('CONFIRM_TABLE', $table_prefix . 'confirm'); define('DISALLOW_TABLE', $table_prefix . 'disallow'); define('DRAFTS_TABLE', $table_prefix . 'drafts'); diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index c423e29d9d..be032440b9 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2818,8 +2818,8 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa $user->lang[$result['error_msg']], ($config['email_enable']) ? '<a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=sendpassword') . '">' : '', ($config['email_enable']) ? '</a>' : '', - ($config['board_contact']) ? '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">' : '', - ($config['board_contact']) ? '</a>' : '' + '<a href="' . phpbb_get_board_contact_link($config, $phpbb_root_path, $phpEx) . '">', + '</a>' ); break; @@ -2830,7 +2830,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa // Assign admin contact to some error messages if ($result['error_msg'] == 'LOGIN_ERROR_USERNAME' || $result['error_msg'] == 'LOGIN_ERROR_PASSWORD') { - $err = (!$config['board_contact']) ? sprintf($user->lang[$result['error_msg']], '', '') : sprintf($user->lang[$result['error_msg']], '<a href="mailto:' . htmlspecialchars($config['board_contact']) . '">', '</a>'); + $err = sprintf($user->lang[$result['error_msg']], '<a href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contactadmin') . '">', '</a>'); } break; @@ -4922,6 +4922,7 @@ function page_header($page_title = '', $display_online_list = false, $item_id = 'U_SEARCH_UNREAD' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=unreadposts'), 'U_SEARCH_ACTIVE_TOPICS'=> append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=active_topics'), 'U_DELETE_COOKIES' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=delete_cookies'), + 'U_CONTACT_US' => ($config['contact_admin_form_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contactadmin') : '', 'U_TEAM' => ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) ? '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=team'), 'U_TERMS_USE' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=terms'), 'U_PRIVACY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=privacy'), @@ -5298,3 +5299,42 @@ function phpbb_convert_30_dbms_to_31($dbms) throw new \RuntimeException("You have specified an invalid dbms driver: $dbms"); } + +/** +* Get the board contact details (e.g. for emails) +* +* @param \phpbb\config\config $config +* @param string $phpEx +* @return string +*/ +function phpbb_get_board_contact(\phpbb\config\config $config, $phpEx) +{ + if ($config['contact_admin_form_enable']) + { + return generate_board_url() . '/memberlist.' . $phpEx . '?mode=contactadmin'; + } + else + { + return $config['board_contact']; + } +} + +/** +* Get a clickable board contact details link +* +* @param \phpbb\config\config $config +* @param string $phpbb_root_path +* @param string $phpEx +* @return string +*/ +function phpbb_get_board_contact_link(\phpbb\config\config $config, $phpbb_root_path, $phpEx) +{ + if ($config['contact_admin_form_enable']) + { + return append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contactadmin'); + } + else + { + return 'mailto:' . htmlspecialchars($config['board_contact']); + } +} diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 3dcb32350e..fafe29f957 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1746,25 +1746,21 @@ function validate_password($password) } /** -* Check to see if email address is banned or already present in the DB +* Check to see if email address is a valid address and contains a MX record * * @param string $email The email to check -* @param string $allowed_email An allowed email, default being $user->data['user_email'] * * @return mixed Either false if validation succeeded or a string which will be used as the error message (with the variable name appended) */ -function validate_email($email, $allowed_email = false) +function phpbb_validate_email($email, $config = null) { - global $config, $db, $user; - - $email = strtolower($email); - $allowed_email = ($allowed_email === false) ? strtolower($user->data['user_email']) : strtolower($allowed_email); - - if ($allowed_email == $email) + if ($config === null) { - return false; + global $config; } + $email = strtolower($email); + if (!preg_match('/^' . get_preg_expression('email') . '$/i', $email)) { return 'EMAIL_INVALID'; @@ -1782,6 +1778,35 @@ function validate_email($email, $allowed_email = false) } } + return false; +} + +/** +* Check to see if email address is banned or already present in the DB +* +* @param string $email The email to check +* @param string $allowed_email An allowed email, default being $user->data['user_email'] +* +* @return mixed Either false if validation succeeded or a string which will be used as the error message (with the variable name appended) +*/ +function validate_user_email($email, $allowed_email = false) +{ + global $config, $db, $user; + + $email = strtolower($email); + $allowed_email = ($allowed_email === false) ? strtolower($user->data['user_email']) : strtolower($allowed_email); + + if ($allowed_email == $email) + { + return false; + } + + $validate_email = phpbb_validate_email($email, $config); + if ($validate_email) + { + return $validate_email; + } + if (($ban_reason = $user->check_ban(false, false, $email, true)) !== false) { return ($ban_reason === true) ? 'EMAIL_BANNED' : $ban_reason; diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index c7ed12f4ee..5ba5f1e830 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -66,7 +66,7 @@ class ucp_profile 'password_confirm' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), 'email' => array( array('string', false, 6, 60), - array('email')), + array('user_email')), ); if ($auth->acl_get('u_chgname') && $config['allow_namechange']) diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index cdd5532429..97934fc32d 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -211,7 +211,7 @@ class ucp_register 'password_confirm' => array('string', false, $config['min_pass_chars'], $config['max_pass_chars']), 'email' => array( array('string', false, 6, 60), - array('email')), + array('user_email')), 'tz' => array('timezone'), 'lang' => array('language_iso_name'), )); diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index e335c1f9ba..15cd9595c6 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -82,6 +82,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('confirm_refresh', INSERT INTO phpbb_config (config_name, config_value) VALUES ('check_attachment_content', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('check_dnsbl', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('chg_passforce', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('contact_admin_form_enable', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('cookie_domain', ''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('cookie_name', 'phpbb3'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('cookie_path', '/'); @@ -299,6 +300,12 @@ INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('sessio INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('upload_dir_size', '0', 1); INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('warnings_last_gc', '0', 1); +# Config text +INSERT INTO phpbb_config_text (config_name, config_value) VALUES ('contact_admin_info', ''); +INSERT INTO phpbb_config_text (config_name, config_value) VALUES ('contact_admin_info_uid', ''); +INSERT INTO phpbb_config_text (config_name, config_value) VALUES ('contact_admin_info_bitfield', ''); +INSERT INTO phpbb_config_text (config_name, config_value) VALUES ('contact_admin_info_flags', '7'); + # -- Forum related auth options INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_', 1); INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_announce', 1); diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index 7dd83e83db..8ab7be2abd 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -352,6 +352,19 @@ $lang = array_merge($lang, array( 'SESSION_LENGTH_EXPLAIN' => 'Sessions will expire after this time, in seconds.', )); +// Contact Settings +$lang = array_merge($lang, array( + 'ACP_CONTACT_SETTINGS_EXPLAIN' => 'Here you can enable and disable the contact page and also add a text that is displayed on the page.', + + 'CONTACT_US_ENABLE' => 'Enable contact page', + 'CONTACT_US_ENABLE_EXPLAIN' => 'This page allows users to send emails to board administrators', + + 'CONTACT_US_INFO' => 'Contact information', + 'CONTACT_US_INFO_EXPLAIN' => 'The message is displayed on the contact page', + 'CONTACT_US_INFO_PREVIEW' => 'Contact page information - Preview', + 'CONTACT_US_INFO_UPDATED' => 'Contact page information has been updated.', +)); + // Load Settings $lang = array_merge($lang, array( 'ACP_LOAD_SETTINGS_EXPLAIN' => 'Here you can enable and disable certain board functions to reduce the amount of processing required. On most servers there is no need to disable any functions. However on certain systems or in shared hosting environments it may be beneficial to disable capabilities you do not really need. You can also specify limits for system load and active sessions beyond which the board will go offline.', diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 6ca1a985a5..8470014161 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -75,6 +75,8 @@ $lang = array_merge($lang, array( 'ACP_CAT_USERS' => 'Users', 'ACP_CLIENT_COMMUNICATION' => 'Client communication', 'ACP_COOKIE_SETTINGS' => 'Cookie settings', + 'ACP_CONTACT' => 'Contact page', + 'ACP_CONTACT_SETTINGS' => 'Contact page settings', 'ACP_CRITICAL_LOGS' => 'Error log', 'ACP_CUSTOM_PROFILE_FIELDS' => 'Custom profile fields', diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 2020783100..91be876514 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -171,6 +171,7 @@ $lang = array_merge($lang, array( 'CONNECTION_SUCCESS' => 'Connection was successful!', 'CONTACT' => 'Contact', 'CONTACT_USER' => 'Contact %s', + 'CONTACT_US' => 'Contact us', 'COOKIES_DELETED' => 'All board cookies successfully deleted.', 'CURRENT_TIME' => 'It is currently %s', @@ -668,8 +669,8 @@ $lang = array_merge($lang, array( 'SELECT_ALL_CODE' => 'Select all', 'SELECT_DESTINATION_FORUM' => 'Please select a destination forum', 'SELECT_FORUM' => 'Select a forum', - 'SEND_EMAIL' => 'Email', // Used for submit buttons - 'SEND_EMAIL_USER' => 'Email %s', + 'SEND_EMAIL' => 'Send email', // Used for submit buttons + 'SEND_EMAIL_USER' => 'Send email to %s', 'SEND_PRIVATE_MESSAGE' => 'Send private message', 'SETTINGS' => 'Settings', 'SIGNATURE' => 'Signature', @@ -732,7 +733,7 @@ $lang = array_merge($lang, array( 'TOO_SHORT_USER_PASSWORD' => 'The password you entered is too short.', 'TOO_SHORT_USERNAME' => 'The username you entered is too short.', 'TOO_SHORT_EMAIL' => 'The email address you entered is too short.', - + 'TOO_SHORT_EMAIL_CONFIRM' => 'The email address confirmation you entered is too short.', 'TOO_SMALL' => 'The value you entered is too small.', 'TOO_SMALL_MAX_RECIPIENTS' => 'The value of <strong>Maximum number of allowed recipients per private message</strong> setting you entered is too small.', diff --git a/phpBB/language/en/email/contact_admin.txt b/phpBB/language/en/email/contact_admin.txt new file mode 100644 index 0000000000..c895c4d687 --- /dev/null +++ b/phpBB/language/en/email/contact_admin.txt @@ -0,0 +1,23 @@ + +Hello {TO_USERNAME}, + +The following is an e-mail sent to you through the administration contact page on "{SITENAME}". + +<!-- IF S_IS_REGISTERED --> +The message has been sent from an account on the site. +Username: {FROM_USERNAME} +E-mail address: {FROM_EMAIL_ADDRESS} +IP Address: {FROM_IP_ADDRESS} +Profile: {U_FROM_PROFILE} +<!-- ELSE --> +The message was sent from a guest who specified the following contact information: +Name: {FROM_USERNAME} +E-mail address: {FROM_EMAIL_ADDRESS} +IP Address: {FROM_IP_ADDRESS} +<!-- ENDIF --> + + +Message sent to you follows +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +{MESSAGE} diff --git a/phpBB/language/en/memberlist.php b/phpBB/language/en/memberlist.php index 7b6838e6d9..d900ababd1 100644 --- a/phpBB/language/en/memberlist.php +++ b/phpBB/language/en/memberlist.php @@ -49,6 +49,8 @@ $lang = array_merge($lang, array( 'BEFORE' => 'Before', 'CC_EMAIL' => 'Send a copy of this email to yourself.', + 'CONTACT_USER' => 'Contact', + 'CONTACT_ADMIN' => 'Contact a Board Administrator', 'DEST_LANG' => 'Language', 'DEST_LANG_EXPLAIN' => 'Select an appropriate language (if available) for the recipient of this message.', @@ -61,6 +63,8 @@ $lang = array_merge($lang, array( 'EMPTY_MESSAGE_EMAIL' => 'You must enter a message to be emailed.', 'EMPTY_MESSAGE_IM' => 'You must enter a message to be send.', 'EMPTY_NAME_EMAIL' => 'You must enter the real name of the recipient.', + 'EMPTY_SENDER_EMAIL' => 'You must provide a valid email address.', + 'EMPTY_SENDER_NAME' => 'You must provide a name.', 'EMPTY_SUBJECT_EMAIL' => 'You must specify a subject for the email.', 'EQUAL_TO' => 'Equal to', @@ -98,6 +102,8 @@ $lang = array_merge($lang, array( 'MORE_THAN' => 'More than', + 'NO_CONTACT_FORM' => 'The board administrator contact form has been disabled.', + 'NO_CONTACT_PAGE' => 'The board administrator contact page has been disabled.', 'NO_EMAIL' => 'You are not permitted to send email to this user.', 'NO_VIEW_USERS' => 'You are not authorised to view the member list or profiles.', @@ -113,6 +119,8 @@ $lang = array_merge($lang, array( 'SELECT_MARKED' => 'Select marked', 'SELECT_SORT_METHOD' => 'Select sort method', + 'SENDER_EMAIL_ADDRESS' => 'Your email address', + 'SENDER_NAME' => 'Your name', 'SEND_ICQ_MESSAGE' => 'Send ICQ message', 'SEND_IM' => 'Instant messaging', 'SEND_JABBER_MESSAGE' => 'Send Jabber message', diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 187b4b1cd9..4eb6d79272 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -20,6 +20,14 @@ $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); include($phpbb_root_path . 'includes/functions_display.' . $phpEx); +$mode = request_var('mode', ''); + +if ($mode === 'contactadmin') +{ + define('SKIP_CHECK_BAN', true); + define('SKIP_CHECK_DISABLED', true); +} + // Start session management $user->session_begin(); $auth->acl($user->data); @@ -29,7 +37,6 @@ $user->setup(array('memberlist', 'groups')); $template->assign_var('S_IN_MEMBERLIST', true); // Grab data -$mode = request_var('mode', ''); $action = request_var('action', ''); $user_id = request_var('u', ANONYMOUS); $username = request_var('un', '', true); @@ -44,7 +51,7 @@ if ($mode == 'leaders') } // Check our mode... -if (!in_array($mode, array('', 'group', 'viewprofile', 'email', 'contact', 'searchuser', 'team', 'livesearch'))) +if (!in_array($mode, array('', 'group', 'viewprofile', 'email', 'contact', 'contactadmin', 'searchuser', 'team', 'livesearch'))) { trigger_error('NO_MODE'); } @@ -52,6 +59,7 @@ if (!in_array($mode, array('', 'group', 'viewprofile', 'email', 'contact', 'sear switch ($mode) { case 'email': + case 'contactadmin': break; case 'livesearch': @@ -386,7 +394,7 @@ switch ($mode) $messenger->set_addresses($row); $messenger->assign_vars(array( - 'BOARD_CONTACT' => $config['board_contact'], + 'BOARD_CONTACT' => phpbb_get_board_contact($config, $phpEx), 'FROM_USERNAME' => htmlspecialchars_decode($user->data['username']), 'TO_USERNAME' => htmlspecialchars_decode($row['username']), 'MESSAGE' => htmlspecialchars_decode($message)) @@ -660,6 +668,7 @@ switch ($mode) 'POSTS_IN_QUEUE'=> $member['posts_in_queue'], 'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']), + 'L_SEND_EMAIL_USER' => $user->lang('SEND_EMAIL_USER', $member['username']), 'EMAIL_IMG' => $user->img('icon_contact_email', $user->lang['EMAIL']), 'JABBER_IMG' => $user->img('icon_contact_jabber', $user->lang['JABBER']), 'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']), @@ -736,265 +745,50 @@ switch ($mode) break; + case 'contactadmin': case 'email': - - // Send an email - $page_title = $user->lang['SEND_EMAIL']; - $template_html = 'memberlist_email.html'; - - add_form_key('memberlist_email'); - - if (!$config['email_enable']) - { - trigger_error('EMAIL_DISABLED'); - } - - if (!$auth->acl_get('u_sendemail')) - { - trigger_error('NO_EMAIL'); - } - - // Are we trying to abuse the facility? - if (time() - $user->data['user_emailtime'] < $config['flood_interval']) + if (!class_exists('messenger')) { - trigger_error('FLOOD_EMAIL_LIMIT'); + include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); } - // Determine action... - $user_id = request_var('u', 0); - $topic_id = request_var('t', 0); + $user_id = request_var('u', 0); + $topic_id = request_var('t', 0); - // Send email to user... if ($user_id) { - if ($user_id == ANONYMOUS || !$config['board_email_form']) - { - trigger_error('NO_EMAIL'); - } - - // Get the appropriate username, etc. - $sql = 'SELECT username, user_email, user_allow_viewemail, user_lang, user_jabber, user_notify_type - FROM ' . USERS_TABLE . " - WHERE user_id = $user_id - AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')'; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error('NO_USER'); - } - - // Can we send email to this user? - if (!$row['user_allow_viewemail'] && !$auth->acl_get('a_user')) - { - trigger_error('NO_EMAIL'); - } + $form_name = 'user'; } else if ($topic_id) { - // Send topic heads-up to email address - $sql = 'SELECT forum_id, topic_title - FROM ' . TOPICS_TABLE . " - WHERE topic_id = $topic_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error('NO_TOPIC'); - } - - if ($row['forum_id']) - { - if (!$auth->acl_get('f_read', $row['forum_id'])) - { - trigger_error('SORRY_AUTH_READ'); - } - - if (!$auth->acl_get('f_email', $row['forum_id'])) - { - trigger_error('NO_EMAIL'); - } - } - else - { - // If global announcement, we need to check if the user is able to at least read and email in one forum... - if (!$auth->acl_getf_global('f_read')) - { - trigger_error('SORRY_AUTH_READ'); - } - - if (!$auth->acl_getf_global('f_email')) - { - trigger_error('NO_EMAIL'); - } - } + $form_name = 'topic'; + } + else if ($mode === 'contactadmin') + { + $form_name = 'admin'; } else { trigger_error('NO_EMAIL'); } + $form = $phpbb_container->get('message.form.' . $form_name); - $error = array(); - - $name = utf8_normalize_nfc(request_var('name', '', true)); - $email = request_var('email', ''); - $email_lang = request_var('lang', $config['default_lang']); - $subject = utf8_normalize_nfc(request_var('subject', '', true)); - $message = utf8_normalize_nfc(request_var('message', '', true)); - $cc = (isset($_POST['cc_email'])) ? true : false; - $submit = (isset($_POST['submit'])) ? true : false; - - if ($submit) + $form->bind($request); + $error = $form->check_allow(); + if ($error) { - if (!check_form_key('memberlist_email')) - { - $error[] = 'FORM_INVALID'; - } - if ($user_id) - { - if (!$subject) - { - $error[] = $user->lang['EMPTY_SUBJECT_EMAIL']; - } - - if (!$message) - { - $error[] = $user->lang['EMPTY_MESSAGE_EMAIL']; - } - - $name = $row['username']; - $email_lang = $row['user_lang']; - $email = $row['user_email']; - } - else - { - if (!$email || !preg_match('/^' . get_preg_expression('email') . '$/i', $email)) - { - $error[] = $user->lang['EMPTY_ADDRESS_EMAIL']; - } - - if (!$name) - { - $error[] = $user->lang['EMPTY_NAME_EMAIL']; - } - } - - if (!sizeof($error)) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_emailtime = ' . time() . ' - WHERE user_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); - - include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - $messenger = new messenger(false); - $email_tpl = ($user_id) ? 'profile_send_email' : 'email_notify'; - - $mail_to_users = array(); - - $mail_to_users[] = array( - 'email_lang' => $email_lang, - 'email' => $email, - 'name' => $name, - 'username' => ($user_id) ? $row['username'] : '', - 'to_name' => $name, - 'user_jabber' => ($user_id) ? $row['user_jabber'] : '', - 'user_notify_type' => ($user_id) ? $row['user_notify_type'] : NOTIFY_EMAIL, - 'topic_title' => (!$user_id) ? $row['topic_title'] : '', - 'forum_id' => (!$user_id) ? $row['forum_id'] : 0, - ); - - // Ok, now the same email if CC specified, but without exposing the users email address - if ($cc) - { - $mail_to_users[] = array( - 'email_lang' => $user->data['user_lang'], - 'email' => $user->data['user_email'], - 'name' => $user->data['username'], - 'username' => $user->data['username'], - 'to_name' => $name, - 'user_jabber' => $user->data['user_jabber'], - 'user_notify_type' => ($user_id) ? $user->data['user_notify_type'] : NOTIFY_EMAIL, - 'topic_title' => (!$user_id) ? $row['topic_title'] : '', - 'forum_id' => (!$user_id) ? $row['forum_id'] : 0, - ); - } - - foreach ($mail_to_users as $row) - { - $messenger->template($email_tpl, $row['email_lang']); - $messenger->replyto($user->data['user_email']); - $messenger->to($row['email'], $row['name']); - - if ($user_id) - { - $messenger->subject(htmlspecialchars_decode($subject)); - $messenger->im($row['user_jabber'], $row['username']); - $notify_type = $row['user_notify_type']; - } - else - { - $notify_type = NOTIFY_EMAIL; - } - - $messenger->anti_abuse_headers($config, $user); - - $messenger->assign_vars(array( - 'BOARD_CONTACT' => $config['board_contact'], - 'TO_USERNAME' => htmlspecialchars_decode($row['to_name']), - 'FROM_USERNAME' => htmlspecialchars_decode($user->data['username']), - 'MESSAGE' => htmlspecialchars_decode($message)) - ); - - if ($topic_id) - { - $messenger->assign_vars(array( - 'TOPIC_NAME' => htmlspecialchars_decode($row['topic_title']), - 'U_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f=" . $row['forum_id'] . "&t=$topic_id") - ); - } - - $messenger->send($notify_type); - } - - meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx")); - $message = ($user_id) ? sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>') : sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$row['forum_id']}&t=$topic_id") . '">', '</a>'); - trigger_error($user->lang['EMAIL_SENT'] . '<br /><br />' . $message); - } + trigger_error($error); } - if ($user_id) + if ($request->is_set_post('submit')) { - $template->assign_vars(array( - 'S_SEND_USER' => true, - 'L_SEND_EMAIL_USER' => $user->lang('SEND_EMAIL_USER', $row['username']), - - 'L_EMAIL_BODY_EXPLAIN' => $user->lang['EMAIL_BODY_EXPLAIN'], - 'S_POST_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&u=' . $user_id)) - ); - } - else - { - $template->assign_vars(array( - 'EMAIL' => $email, - 'NAME' => $name, - 'S_LANG_OPTIONS' => language_select($email_lang), - - 'L_EMAIL_BODY_EXPLAIN' => $user->lang['EMAIL_TOPIC_EXPLAIN'], - 'S_POST_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&t=' . $topic_id)) - ); + $messenger = new messenger(false); + $form->submit($messenger); } - $template->assign_vars(array( - 'ERROR_MESSAGE' => (sizeof($error)) ? implode('<br />', $error) : '', - 'SUBJECT' => $subject, - 'MESSAGE' => $message, - ) - ); + $page_title = $form->get_page_title(); + $template_html = $form->get_template_file(); + $form->render($template); break; diff --git a/phpBB/phpbb/avatar/driver/gravatar.php b/phpBB/phpbb/avatar/driver/gravatar.php index 34b894c2a7..c4344ee6e8 100644 --- a/phpBB/phpbb/avatar/driver/gravatar.php +++ b/phpBB/phpbb/avatar/driver/gravatar.php @@ -81,7 +81,8 @@ class gravatar extends \phpbb\avatar\driver\driver array( 'email' => array( array('string', false, 6, 60), - array('email')) + array('email'), + ), ) ); diff --git a/phpBB/phpbb/config/config.php b/phpBB/phpbb/config/config.php index 8cbe1e1e2d..aaad333006 100644 --- a/phpBB/phpbb/config/config.php +++ b/phpBB/phpbb/config/config.php @@ -37,7 +37,7 @@ class config implements \ArrayAccess, \IteratorAggregate, \Countable /** * Retrieves an ArrayIterator over the configuration values. * - * @return ArrayIterator An iterator over all config data + * @return \ArrayIterator An iterator over all config data */ public function getIterator() { diff --git a/phpBB/phpbb/db/migration/data/v310/contact_admin_acp_module.php b/phpBB/phpbb/db/migration/data/v310/contact_admin_acp_module.php new file mode 100644 index 0000000000..bd682e2f7c --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/contact_admin_acp_module.php @@ -0,0 +1,27 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +namespace phpbb\db\migration\data\v310; + +class contact_admin_acp_module extends \phpbb\db\migration\migration +{ + public function update_data() + { + return array( + array('module.add', array( + 'acp', + 'ACP_BOARD_CONFIGURATION', + array( + 'module_basename' => 'acp_contact', + 'modes' => array('contact'), + ), + )), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v310/contact_admin_form.php b/phpBB/phpbb/db/migration/data/v310/contact_admin_form.php new file mode 100644 index 0000000000..e255efb99d --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/contact_admin_form.php @@ -0,0 +1,37 @@ +<?php +/** +* +* @package migration +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +namespace phpbb\db\migration\data\v310; + +class contact_admin_form extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + return isset($this->config['contact_admin_form_enable']); + } + + public function update_data() + { + return array( + array('config.add', array('contact_admin_form_enable', 1)), + array('custom', array(array($this, 'contact_admin_info'))), + ); + } + + public function contact_admin_info() + { + $text_config = new \phpbb\config\db_text($this->db, $this->table_prefix . 'config_text'); + $text_config->set_array(array( + 'contact_admin_info' => '', + 'contact_admin_info_uid' => '', + 'contact_admin_info_bitfield' => '', + 'contact_admin_info_flags' => OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS, + )); + } +} diff --git a/phpBB/phpbb/message/admin_form.php b/phpBB/phpbb/message/admin_form.php new file mode 100644 index 0000000000..b71b3fc535 --- /dev/null +++ b/phpBB/phpbb/message/admin_form.php @@ -0,0 +1,189 @@ +<?php +/** +* +* @package message +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +namespace phpbb\message; + +/** +* Class admin_form +* Displays a message to the user and allows him to send an email +* +* @package phpbb\message +*/ +class admin_form extends form +{ + /** @var \phpbb\config\db_text */ + protected $config_text; + + /** @var string */ + protected $subject; + /** @var string */ + protected $sender_name; + /** @var string */ + protected $sender_address; + + /** + * Construct + * + * @param \phpbb\auth\auth $auth + * @param \phpbb\config\config $config + * @param \phpbb\config\db_text $config_text + * @param \phpbb\db\driver\driver_interface $db + * @param \phpbb\user $user + * @param string $phpbb_root_path + * @param string $phpEx + */ + public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\config\db_text $config_text, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $phpbb_root_path, $phpEx) + { + parent::__construct($auth, $config, $db, $user, $phpbb_root_path, $phpEx); + $this->config_text = $config_text; + } + + /** + * {inheritDoc} + */ + public function check_allow() + { + $error = parent::check_allow(); + if ($error) + { + return $error; + } + + if (!$this->config['contact_admin_form_enable']) + { + return 'NO_CONTACT_PAGE'; + } + + return false; + } + + /** + * {inheritDoc} + */ + public function bind(\phpbb\request\request_interface $request) + { + parent::bind($request); + + $this->subject = $request->variable('subject', '', true); + $this->sender_address = $request->variable('email', ''); + $this->sender_name = $request->variable('name', '', true); + } + + /** + * {inheritDoc} + */ + public function submit(\messenger $messenger) + { + if (!$this->subject) + { + $this->errors[] = $this->user->lang['EMPTY_SUBJECT_EMAIL']; + } + if (!$this->body) + { + $this->errors[] = $this->user->lang['EMPTY_MESSAGE_EMAIL']; + } + + if ($this->user->data['is_registered']) + { + $this->message->set_sender_from_user($this->user); + $this->sender_name = $this->user->data['username']; + $this->sender_address = $this->user->data['user_email']; + } + else + { + if (!$this->sender_name) + { + $this->errors[] = $this->user->lang['EMPTY_SENDER_NAME']; + } + + if (!function_exists('validate_data')) + { + require($this->phpbb_root_path . 'includes/functions_user.' . $this->phpEx); + } + + $validate_array = validate_data( + array( + 'email' => $this->sender_address, + ), + array( + 'email' => array( + array('string', false, 6, 60), + array('email'), + ), + ) + ); + + foreach ($validate_array as $error) + { + $this->errors[] = $this->user->lang[$error]; + } + + $this->message->set_sender($this->user->ip, $this->sender_name, $this->sender_address, $this->user->lang_name); + $this->message->set_sender_notify_type(NOTIFY_EMAIL); + } + + $this->message->set_template('contact_admin'); + $this->message->set_subject($this->subject); + $this->message->set_body($this->body); + $this->message->add_recipient( + $this->user->lang['ADMINISTRATOR'], + $this->config['board_contact'], + $this->config['default_lang'], + NOTIFY_EMAIL + ); + + $this->message->set_template_vars(array( + 'FROM_EMAIL_ADDRESS' => $this->sender_address, + 'FROM_IP_ADDRESS' => $this->user->ip, + 'S_IS_REGISTERED' => $this->user->data['is_registered'], + + 'U_FROM_PROFILE' => generate_board_url() . '/memberlist.' . $this->phpEx . '?mode=viewprofile&u=' . $this->user->data['user_id'], + )); + + parent::submit($messenger); + } + + /** + * {inheritDoc} + */ + public function render(\phpbb\template\template $template) + { + $l_admin_info = $this->config_text->get('contact_admin_info'); + if ($l_admin_info) + { + $contact_admin_data = $this->config_text->get_array(array( + 'contact_admin_info', + 'contact_admin_info_uid', + 'contact_admin_info_bitfield', + 'contact_admin_info_flags', + )); + + $l_admin_info = generate_text_for_display( + $contact_admin_data['contact_admin_info'], + $contact_admin_data['contact_admin_info_uid'], + $contact_admin_data['contact_admin_info_bitfield'], + $contact_admin_data['contact_admin_info_flags'] + ); + } + + $template->assign_vars(array( + 'S_CONTACT_ADMIN' => true, + 'S_CONTACT_FORM' => $this->config['contact_admin_form_enable'], + 'S_IS_REGISTERED' => $this->user->data['is_registered'], + + 'CONTACT_INFO' => $l_admin_info, + 'MESSAGE' => $this->body, + 'SUBJECT' => $this->subject, + 'NAME' => $this->sender_name, + 'EMAIL' => $this->sender_address, + )); + + parent::render($template); + } +} diff --git a/phpBB/phpbb/message/form.php b/phpBB/phpbb/message/form.php new file mode 100644 index 0000000000..d7a42c4080 --- /dev/null +++ b/phpBB/phpbb/message/form.php @@ -0,0 +1,173 @@ +<?php +/** +* +* @package message +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +namespace phpbb\message; + +/** +* Abstract class form +* +* @package phpbb\message +*/ +abstract class form +{ + /** @var \phpbb\auth\auth */ + protected $auth; + /** @var \phpbb\config\config */ + protected $config; + /** @var \phpbb\db\driver\driver_interface */ + protected $db; + /** @var \phpbb\message\message */ + protected $message; + /** @var \phpbb\user */ + protected $user; + + /** @var string */ + protected $phpbb_root_path; + /** @var string */ + protected $phpEx; + + /** @var array */ + protected $errors = array(); + /** @var bool */ + protected $cc_sender; + /** @var string */ + protected $body; + + /** + * Construct + * + * @param \phpbb\auth\auth $auth + * @param \phpbb\config\config $config + * @param \phpbb\db\driver\driver_interface $db + * @param \phpbb\user $user + * @param string $phpbb_root_path + * @param string $phpEx + */ + public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $phpbb_root_path, $phpEx) + { + $this->phpbb_root_path = $phpbb_root_path; + $this->phpEx = $phpEx; + $this->user = $user; + $this->auth = $auth; + $this->config = $config; + $this->db = $db; + + $this->message = new message($config['server_name']); + $this->message->set_sender_from_user($this->user); + } + + /** + * Returns the title for the email form page + * + * @return string + */ + public function get_page_title() + { + return $this->user->lang['SEND_EMAIL']; + } + + /** + * Returns the file name of the form template + * + * @return string + */ + public function get_template_file() + { + return 'memberlist_email.html'; + } + + /** + * Checks whether the user is allowed to use the form + * + * @return false|string Error string if not allowed, false otherwise + */ + public function check_allow() + { + if (!$this->config['email_enable']) + { + return 'EMAIL_DISABLED'; + } + + if (time() - $this->user->data['user_emailtime'] < $this->config['flood_interval']) + { + return 'FLOOD_EMAIL_LIMIT'; + } + + return false; + } + + /** + * Get the return link after the message has been sent + * + * @return string + */ + public function get_return_message() + { + return sprintf($this->user->lang['RETURN_INDEX'], '<a href="' . append_sid($this->phpbb_root_path . 'index.' . $this->phpEx) . '">', '</a>'); + } + + /** + * Bind the values of the request to the form + * + * @param \phpbb\request\request_interface $request + * @return null + */ + public function bind(\phpbb\request\request_interface $request) + { + $this->cc_sender = $request->is_set_post('cc_sender'); + $this->body = $request->variable('message', '', true); + } + + /** + * Submit form, generate the email and send it + * + * @param \messenger $messenger + * @return null + */ + public function submit(\messenger $messenger) + { + if (!check_form_key('memberlist_email')) + { + $this->errors[] = 'FORM_INVALID'; + } + + if (!sizeof($this->errors)) + { + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_emailtime = ' . time() . ' + WHERE user_id = ' . $this->user->data['user_id']; + $this->db->sql_query($sql); + + if ($this->cc_sender) + { + $this->message->cc_sender(); + } + + $this->message->send($messenger, phpbb_get_board_contact($this->config, $this->phpEx)); + + meta_refresh(3, append_sid($this->phpbb_root_path . 'index.' . $this->phpEx)); + trigger_error($this->user->lang['EMAIL_SENT'] . '<br /><br />' . $this->get_return_message()); + } + } + + /** + * Render the template of the form + * + * @param \phpbb\template\template $template + * @return null + */ + public function render(\phpbb\template\template $template) + { + add_form_key('memberlist_email'); + + $template->assign_vars(array( + 'ERROR_MESSAGE' => (sizeof($this->errors)) ? implode('<br />', $this->errors) : '', + )); + } +} diff --git a/phpBB/phpbb/message/message.php b/phpBB/phpbb/message/message.php new file mode 100644 index 0000000000..182995ba21 --- /dev/null +++ b/phpBB/phpbb/message/message.php @@ -0,0 +1,280 @@ +<?php +/** +* +* @package message +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +namespace phpbb\message; + +/** +* Class message +* Holds all information for an email and sends it in the end +* +* @package phpbb\message +*/ +class message +{ + /** @var string */ + protected $server_name; + + /** @var string */ + protected $subject = ''; + /** @var string */ + protected $body = ''; + /** @var string */ + protected $template = ''; + /** @var array */ + protected $template_vars = array(); + + /** @var string */ + protected $sender_ip = ''; + /** @var string */ + protected $sender_name = ''; + /** @var string */ + protected $sender_address = ''; + /** @var string */ + protected $sender_lang = ''; + /** @var string */ + protected $sender_id = ''; + /** @var string */ + protected $sender_username = ''; + /** @var string */ + protected $sender_jabber = ''; + /** @var int */ + protected $sender_notify_type = NOTIFY_EMAIL; + + /** @var array */ + protected $recipients; + + /** + * Construct + * + * @param string $server_name Used for AntiAbuse header + */ + public function __construct($server_name) + { + $this->server_name = $server_name; + } + + /** + * Set the subject of the email + * + * @param string $subject + * @return null + */ + public function set_subject($subject) + { + $this->subject = $subject; + } + + /** + * Set the body of the email text + * + * @param string $body + * @return null + */ + public function set_body($body) + { + $this->body = $body; + } + + /** + * Set the name of the email template to use + * + * @param string $template + * @return null + */ + public function set_template($template) + { + $this->template = $template; + } + + /** + * Set the array with the "template" data for the email + * + * @param array $template_vars + * @return null + */ + public function set_template_vars($template_vars) + { + $this->template_vars = $template_vars; + } + + /** + * Add a recipient from \phpbb\user + * + * @param \phpbb\user $user + * @return null + */ + public function add_recipient_from_user_row(array $user) + { + $this->add_recipient( + $user['username'], + $user['user_email'], + $user['user_lang'], + $user['user_notify_type'], + $user['username'], + $user['user_jabber'] + ); + } + + /** + * Add a recipient + * + * @param string $recipient_name Displayed sender name + * @param string $recipient_address Email address + * @param string $recipient_lang + * @param int $recipient_notify_type Used notification methods (Jabber, Email, ...) + * @param string $recipient_username User Name (used for AntiAbuse header) + * @param string $recipient_jabber + * @return null + */ + public function add_recipient($recipient_name, $recipient_address, $recipient_lang, $recipient_notify_type = NOTIFY_EMAIL, $recipient_username = '', $recipient_jabber = '') + { + $this->recipients[] = array( + 'name' => $recipient_name, + 'address' => $recipient_address, + 'lang' => $recipient_lang, + 'username' => $recipient_username, + 'jabber' => $recipient_jabber, + 'notify_type' => $recipient_notify_type, + 'to_name' => $recipient_name, + ); + } + + /** + * Set the senders data from \phpbb\user object + * + * @param \phpbb\user $user + * @return null + */ + public function set_sender_from_user($user) + { + $this->set_sender( + $user->ip, + $user->data['username'], + $user->data['user_email'], + $user->lang_name, + $user->data['user_id'], + $user->data['username'], + $user->data['user_jabber'] + ); + + $this->set_sender_notify_type($user->data['user_notify_type']); + } + + /** + * Set the senders data + * + * @param string $sender_ip + * @param string $sender_name Displayed sender name + * @param string $sender_address Email address + * @param string $sender_lang + * @param int $sender_id User ID + * @param string $sender_username User Name (used for AntiAbuse header) + * @param string $sender_jabber + * @return null + */ + public function set_sender($sender_ip, $sender_name, $sender_address, $sender_lang = '', $sender_id = 0, $sender_username = '', $sender_jabber = '') + { + $this->sender_ip = $sender_ip; + $this->sender_name = $sender_name; + $this->sender_address = $sender_address; + $this->sender_lang = $sender_lang; + $this->sender_id = $sender_id; + $this->sender_username = $sender_username; + $this->sender_jabber = $sender_jabber; + } + + /** + * Which notification type should be used? Jabber, Email, ...? + * + * @param int $sender_notify_type + * @return null + */ + public function set_sender_notify_type($sender_notify_type) + { + $this->sender_notify_type = $sender_notify_type; + } + + /** + * Ok, now the same email if CC specified, but without exposing the user's email address + * + * @return null + */ + public function cc_sender() + { + if (!sizeof($this->recipients)) + { + trigger_error('No email recipients specified'); + } + if (!$this->sender_address) + { + trigger_error('No email sender specified'); + } + + $this->recipients[] = array( + 'lang' => $this->sender_lang, + 'address' => $this->sender_address, + 'name' => $this->sender_name, + 'username' => $this->sender_username, + 'jabber' => $this->sender_jabber, + 'notify_type' => $this->sender_notify_type, + 'to_name' => $this->recipients[0]['to_name'], + ); + } + + /** + * Send the email + * + * @param \messenger $messenger + * @param string $phpEx + * @return null + */ + public function send(\messenger $messenger, $contact) + { + if (!sizeof($this->recipients)) + { + return; + } + + foreach ($this->recipients as $recipient) + { + $messenger->template($this->template, $recipient['lang']); + $messenger->replyto($this->sender_address); + $messenger->to($recipient['address'], $recipient['name']); + $messenger->im($recipient['jabber'], $recipient['username']); + + $messenger->headers('X-AntiAbuse: Board servername - ' . $this->server_name); + $messenger->headers('X-AntiAbuse: User IP - ' . $this->sender_ip); + + if ($this->sender_id) + { + $messenger->headers('X-AntiAbuse: User_id - ' . $this->sender_id); + } + if ($this->sender_username) + { + $messenger->headers('X-AntiAbuse: Username - ' . $this->sender_username); + } + + $messenger->subject(htmlspecialchars_decode($this->subject)); + + $messenger->assign_vars(array( + 'BOARD_CONTACT' => $contact, + 'TO_USERNAME' => htmlspecialchars_decode($recipient['to_name']), + 'FROM_USERNAME' => htmlspecialchars_decode($this->sender_name), + 'MESSAGE' => htmlspecialchars_decode($this->body)) + ); + + if (sizeof($this->template_vars)) + { + $messenger->assign_vars($this->template_vars); + } + + $messenger->send($recipient['notify_type']); + } + } +} diff --git a/phpBB/phpbb/message/topic_form.php b/phpBB/phpbb/message/topic_form.php new file mode 100644 index 0000000000..3a35c35d21 --- /dev/null +++ b/phpBB/phpbb/message/topic_form.php @@ -0,0 +1,156 @@ +<?php +/** +* +* @package message +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +namespace phpbb\message; + +/** +* Class topic_form +* Form used to send topics as notification emails +* +* @package phpbb\message +*/ +class topic_form extends form +{ + /** @var int */ + protected $topic_id; + /** @var array */ + protected $topic_row; + /** @var string */ + protected $recipient_address; + /** @var string */ + protected $recipient_name; + /** @var string */ + protected $recipient_lang; + + /** + * Get the data of the topic + * + * @param int $topic_id + * @return false|array false if the topic does not exist, array otherwise + */ + protected function get_topic_row($topic_id) + { + $sql = 'SELECT forum_id, topic_title + FROM ' . TOPICS_TABLE . ' + WHERE topic_id = ' . (int) $topic_id; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + return $row; + } + + /** + * {inheritDoc} + */ + public function check_allow() + { + $error = parent::check_allow(); + if ($error) + { + return $error; + } + + if (!$this->auth->acl_get('u_sendemail')) + { + return 'NO_EMAIL'; + } + + if (!$this->topic_row) + { + return 'NO_TOPIC'; + } + + if (!$this->auth->acl_get('f_read', $this->topic_row['forum_id'])) + { + return 'SORRY_AUTH_READ'; + } + + if (!$this->auth->acl_get('f_email', $this->topic_row['forum_id'])) + { + return 'NO_EMAIL'; + } + + return false; + } + + /** + * {inheritDoc} + */ + public function bind(\phpbb\request\request_interface $request) + { + parent::bind($request); + + $this->topic_id = $request->variable('t', 0); + $this->recipient_address = $request->variable('email', ''); + $this->recipient_name = $request->variable('name', '', true); + $this->recipient_lang = $request->variable('lang', $this->config['default_lang']); + + $this->topic_row = $this->get_topic_row($this->topic_id); + } + + /** + * {inheritDoc} + */ + public function submit(\messenger $messenger) + { + if (!$this->recipient_address || !preg_match('/^' . get_preg_expression('email') . '$/i', $this->recipient_address)) + { + $this->errors[] = $this->user->lang['EMPTY_ADDRESS_EMAIL']; + } + + if (!$this->recipient_name) + { + $this->errors[] = $this->user->lang['EMPTY_NAME_EMAIL']; + } + + $this->message->set_template('email_notify'); + $this->message->set_template_vars(array( + 'TOPIC_NAME' => htmlspecialchars_decode($this->topic_row['topic_title']), + 'U_TOPIC' => generate_board_url() . '/viewtopic.' . $this->phpEx . '?f=' . $this->topic_row['forum_id'] . '&t=' . $this->topic_id, + )); + + $this->message->add_recipient( + $this->recipient_name, + $this->recipient_address, + $this->recipient_lang, + NOTIFY_EMAIL + ); + $this->message->set_sender_notify_type(NOTIFY_EMAIL); + + parent::submit($messenger); + } + + /** + * {inheritDoc} + */ + public function get_return_message() + { + return sprintf($this->user->lang['RETURN_TOPIC'], '<a href="' . append_sid($this->phpbb_root_path . 'viewtopic.' . $this->phpEx, 'f=' . $this->topic_row['forum_id'] . '&t=' . $this->topic_id) . '">', '</a>'); + } + + /** + * {inheritDoc} + */ + public function render(\phpbb\template\template $template) + { + parent::render($template); + + $this->user->add_lang('viewtopic'); + $template->assign_vars(array( + 'EMAIL' => $this->recipient_address, + 'NAME' => $this->recipient_name, + 'S_LANG_OPTIONS' => language_select($this->recipient_lang), + 'MESSAGE' => $this->body, + + 'L_EMAIL_BODY_EXPLAIN' => $this->user->lang['EMAIL_TOPIC_EXPLAIN'], + 'S_POST_ACTION' => append_sid($this->phpbb_root_path . 'memberlist.' . $this->phpEx, 'mode=email&t=' . $this->topic_id)) + ); + } +} diff --git a/phpBB/phpbb/message/user_form.php b/phpBB/phpbb/message/user_form.php new file mode 100644 index 0000000000..7aa4b94def --- /dev/null +++ b/phpBB/phpbb/message/user_form.php @@ -0,0 +1,134 @@ +<?php +/** +* +* @package message +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +namespace phpbb\message; + +/** +* Class user_form +* Allows users to send emails to other users +* +* @package phpbb\message +*/ +class user_form extends form +{ + /** @var int */ + protected $recipient_id; + /** @var array */ + protected $recipient_row; + /** @var string */ + protected $subject; + + /** + * Get the data of the recipient + * + * @param int $user_id + * @return false|array false if the user does not exist, array otherwise + */ + protected function get_user_row($user_id) + { + $sql = 'SELECT user_id, username, user_colour, user_email, user_allow_viewemail, user_lang, user_jabber, user_notify_type + FROM ' . USERS_TABLE . ' + WHERE user_id = ' . (int) $user_id . ' + AND user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')'; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + return $row; + } + + /** + * {inheritDoc} + */ + public function check_allow() + { + $error = parent::check_allow(); + if ($error) + { + return $error; + } + + if (!$this->auth->acl_get('u_sendemail')) + { + return 'NO_EMAIL'; + } + + if ($this->recipient_id == ANONYMOUS || !$this->config['board_email_form']) + { + return 'NO_EMAIL'; + } + + if (!$this->recipient_row) + { + return 'NO_USER'; + } + + // Can we send email to this user? + if (!$this->recipient_row['user_allow_viewemail'] && !$this->auth->acl_get('a_user')) + { + return 'NO_EMAIL'; + } + + return false; + } + + /** + * {inheritDoc} + */ + public function bind(\phpbb\request\request_interface $request) + { + parent::bind($request); + + $this->recipient_id = $request->variable('u', 0); + $this->subject = $request->variable('subject', '', true); + + $this->recipient_row = $this->get_user_row($this->recipient_id); + } + + /** + * {inheritDoc} + */ + public function submit(\messenger $messenger) + { + if (!$this->subject) + { + $this->errors[] = $this->user->lang['EMPTY_SUBJECT_EMAIL']; + } + + if (!$this->body) + { + $this->errors[] = $this->user->lang['EMPTY_MESSAGE_EMAIL']; + } + + $this->message->set_template('profile_send_email'); + $this->message->set_subject($this->subject); + $this->message->set_body($this->body); + $this->message->add_recipient_from_user_row($this->recipient_row); + + parent::submit($messenger); + } + + /** + * {inheritDoc} + */ + public function render(\phpbb\template\template $template) + { + parent::render($template); + + $template->assign_vars(array( + 'S_SEND_USER' => true, + 'S_POST_ACTION' => append_sid($this->phpbb_root_path . 'memberlist.' . $this->phpEx, 'mode=email&u=' . $this->recipient_id), + + 'L_SEND_EMAIL_USER' => $this->user->lang('SEND_EMAIL_USER', $this->recipient_row['username']), + 'USERNAME_FULL' => get_username_string('full', $this->recipient_row['user_id'], $this->recipient_row['username'], $this->recipient_row['user_colour']), + 'SUBJECT' => $this->subject, + 'MESSAGE' => $this->body, + )); + } +} diff --git a/phpBB/phpbb/session.php b/phpBB/phpbb/session.php index d286dc9cfc..c2669ea6cc 100644 --- a/phpBB/phpbb/session.php +++ b/phpBB/phpbb/session.php @@ -1075,7 +1075,7 @@ class session { global $config, $db; - if (defined('IN_CHECK_BAN')) + if (defined('IN_CHECK_BAN') || defined('SKIP_CHECK_BAN')) { return; } @@ -1189,7 +1189,7 @@ class session if ($banned && !$return) { - global $template; + global $template, $phpbb_root_path, $phpEx; // If the session is empty we need to create a valid one... if (empty($this->session_id)) @@ -1210,8 +1210,6 @@ class session // We show a login box here to allow founders accessing the board if banned by IP if (defined('IN_LOGIN') && $this->data['user_id'] == ANONYMOUS) { - global $phpEx; - $this->setup('ucp'); $this->data['is_registered'] = $this->data['is_bot'] = false; @@ -1235,7 +1233,8 @@ class session $till_date = ($ban_row['ban_end']) ? $this->format_date($ban_row['ban_end']) : ''; $message = ($ban_row['ban_end']) ? 'BOARD_BAN_TIME' : 'BOARD_BAN_PERM'; - $message = sprintf($this->lang[$message], $till_date, '<a href="mailto:' . $config['board_contact'] . '">', '</a>'); + $contact_link = phpbb_get_board_contact_link($config, $phpbb_root_path, $phpEx); + $message = sprintf($this->lang[$message], $till_date, '<a href="' . $contact_link . '">', '</a>'); $message .= ($ban_row['ban_give_reason']) ? '<br /><br />' . sprintf($this->lang['BOARD_BAN_REASON'], $ban_row['ban_give_reason']) : ''; $message .= '<br /><br /><em>' . $this->lang['BAN_TRIGGERED_BY_' . strtoupper($ban_triggered_by)] . '</em>'; diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php index f4cc26cc9a..4e90044395 100644 --- a/phpBB/phpbb/user.php +++ b/phpBB/phpbb/user.php @@ -317,7 +317,7 @@ class user extends \phpbb\session } // Is board disabled and user not an admin or moderator? - if ($config['board_disable'] && !defined('IN_LOGIN') && !$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) + if ($config['board_disable'] && !defined('IN_LOGIN') && !defined('SKIP_CHECK_DISABLED') && !$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) { if ($this->data['is_bot']) { diff --git a/phpBB/styles/prosilver/template/memberlist_email.html b/phpBB/styles/prosilver/template/memberlist_email.html index 78d0eba5a8..865f0b883c 100644 --- a/phpBB/styles/prosilver/template/memberlist_email.html +++ b/phpBB/styles/prosilver/template/memberlist_email.html @@ -1,24 +1,62 @@ <!-- INCLUDE overall_header.html --> +<!-- IF S_CONTACT_ADMIN--> +<h2 class="titlespace">{L_CONTACT_ADMIN}</h2> +<!-- ELSEIF S_SEND_USER --> <h2 class="titlespace">{L_SEND_EMAIL_USER}</h2> +<!-- ELSE --> +<h2 class="titlespace">{L_EMAIL_TOPIC}</h2> +<!-- ENDIF --> <form method="post" action="{S_POST_ACTION}" id="post"> -<div class="panel"> - <div class="inner"> + <!-- IF CONTACT_INFO --> + <div class="panel"> + <div class="inner"> + <div class="postbody"> + <div class="content"> + {CONTACT_INFO} + </div> + </div> + </div> + </div> + <br class="clear" /> + <!-- ENDIF --> + <div class="panel"> + <div class="inner"> <div class="content"> + <!-- IF ERROR_MESSAGE --><p class="error">{ERROR_MESSAGE}</p><!-- ENDIF --> <fieldset class="fields2"> <!-- IF S_SEND_USER --> <dl> <dt><label>{L_RECIPIENT}{L_COLON}</label></dt> - <dd><strong>{USERNAME}</strong></dd> + <dd><strong>{USERNAME_FULL}</strong></dd> </dl> <dl> <dt><label for="subject">{L_SUBJECT}{L_COLON}</label></dt> <dd><input class="inputbox autowidth" type="text" name="subject" id="subject" size="50" tabindex="1" value="{SUBJECT}" /></dd> </dl> + <!-- ELSEIF S_CONTACT_ADMIN--> + <dl> + <dt><label>{L_RECIPIENT}:</label></dt> + <dd><strong>{L_ADMINISTRATOR}</strong></dd> + </dl> + <!-- IF not S_IS_REGISTERED --> + <dl> + <dt><label for="email">{L_SENDER_EMAIL_ADDRESS}:</label></dt> + <dd><input class="inputbox autowidth" type="text" name="email" id="email" size="50" maxlength="100" tabindex="1" value="{EMAIL}" /></dd> + </dl> + <dl> + <dt><label for="name">{L_SENDER_NAME}:</label></dt> + <dd><input class="inputbox autowidth" type="text" name="name" id="name" size="50" tabindex="2" value="{NAME}" /></dd> + </dl> + <!-- ENDIF --> + <dl> + <dt><label for="subject">{L_SUBJECT}:</label></dt> + <dd><input class="inputbox autowidth" type="text" name="subject" id="subject" size="50" tabindex="3" value="{SUBJECT}" /></dd> + </dl> <!-- ELSE --> <dl> <dt><label for="email">{L_EMAIL_ADDRESS}{L_COLON}</label></dt> diff --git a/phpBB/styles/prosilver/template/navbar_footer.html b/phpBB/styles/prosilver/template/navbar_footer.html index 13e50dae19..6912ee242e 100644 --- a/phpBB/styles/prosilver/template/navbar_footer.html +++ b/phpBB/styles/prosilver/template/navbar_footer.html @@ -16,6 +16,7 @@ <!-- IF not S_IS_BOT --><li class="rightside"><a href="{U_DELETE_COOKIES}" data-ajax="true" data-refresh="true">{L_DELETE_COOKIES}</a></li><!-- ENDIF --> <!-- EVENT overall_footer_teamlink_before --> <!-- IF U_TEAM --><li class="rightside"><a href="{U_TEAM}">{L_THE_TEAM}</a></li><!-- ENDIF --> + <!-- IF U_CONTACT_US --><li class="rightside"><a href="{U_CONTACT_US}">{L_CONTACT_US}</a></li><!-- ENDIF --> <!-- EVENT overall_footer_teamlink_after --> </ul> diff --git a/phpBB/styles/subsilver2/template/index_body.html b/phpBB/styles/subsilver2/template/index_body.html index cb67768b15..2fdd0c77c1 100644 --- a/phpBB/styles/subsilver2/template/index_body.html +++ b/phpBB/styles/subsilver2/template/index_body.html @@ -20,10 +20,14 @@ <!-- IF not S_IS_BOT and U_TEAM --> | <!-- ENDIF --> <!-- EVENT overall_footer_teamlink_before --> <!-- IF U_TEAM --><a href="{U_TEAM}">{L_THE_TEAM}</a><!-- ENDIF --> + <!-- IF U_CONTACT_US --> + <!-- IF U_TEAM --> | <!-- ENDIF --> + <a href="{U_CONTACT_US}">{L_CONTACT_US}</a> + <!-- ENDIF --> <!-- EVENT overall_footer_teamlink_after --> </span> -<br /> <!-- ENDIF --> +<br /> <br clear="all" /> diff --git a/phpBB/styles/subsilver2/template/memberlist_email.html b/phpBB/styles/subsilver2/template/memberlist_email.html index 7693a4167f..13ff4baace 100644 --- a/phpBB/styles/subsilver2/template/memberlist_email.html +++ b/phpBB/styles/subsilver2/template/memberlist_email.html @@ -6,13 +6,24 @@ <table class="tablebg" width="100%" cellspacing="1"> <tr> + <!-- IF S_CONTACT_ADMIN--> + <th colspan="2">{L_CONTACT_ADMIN}</th> + <!-- ELSEIF S_SEND_USER --> <th colspan="2">{L_SEND_EMAIL_USER}</th> + <!-- ELSE --> + <th colspan="2">{L_EMAIL_TOPIC}</th> + <!-- ENDIF --> </tr> <!-- IF ERROR_MESSAGE --> <tr> <td class="row3" colspan="2" align="center"><span class="error">{ERROR_MESSAGE}</span></td> </tr> <!-- ENDIF --> + <!-- IF CONTACT_INFO --> + <tr> + <td class="row1" colspan="2">{CONTACT_INFO}</td> + </tr> + <!-- ENDIF --> <!-- IF S_SEND_USER --> <tr> <td class="row1" width="35%"><b class="genmed">{L_RECIPIENT}</b></td> @@ -22,6 +33,21 @@ <td class="row1" width="35%"><b class="genmed">{L_SUBJECT}</b></td> <td class="row2"><input class="post" type="text" name="subject" size="50" tabindex="2" value="{SUBJECT}" /></td> </tr> + <!-- ELSEIF S_CONTACT_ADMIN--> + <tr> + <td class="row1" width="35%"><b class="genmed">{L_RECIPIENT}</b></td> + <td class="row2" width="65%"><b class="genmed">{L_ADMINISTRATOR}</b></td> + </tr> + <!-- IF not S_IS_REGISTERED --> + <tr> + <td class="row1" width="35%"><b class="genmed">{L_SENDER_EMAIL_ADDRESS}</b></td> + <td class="row2"><input class="post" type="text" name="email" size="50" maxlength="100" value="{EMAIL}" /></td> + </tr> + <tr> + <td class="row1" width="35%"><b class="genmed">{L_SENDER_NAME}</b></td> + <td class="row2"><input class="post" type="text" name="name" size="50" value="{NAME}" /></td> + </tr> + <!-- ENDIF --> <!-- ELSE --> <tr> <td class="row1" width="35%"><b class="genmed">{L_EMAIL_ADDRESS}</b></td> diff --git a/tests/functions/validate_email_test.php b/tests/functions/validate_email_test.php index dbd4b05520..b46509fda7 100644 --- a/tests/functions/validate_email_test.php +++ b/tests/functions/validate_email_test.php @@ -1,13 +1,9 @@ <?php /** * -* This file is part of the phpBB Forum Software package. -* -* @copyright (c) phpBB Limited <https://www.phpbb.com> -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. +* @package testing +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -51,60 +47,54 @@ class phpbb_functions_validate_email_test extends phpbb_database_test_case $user->optionset('banned_users', array('banned@example.com')); } - public function test_validate_email() + public static function validate_email_data() + { + return array( + array('empty', array('EMAIL_INVALID'), ''), // email does not allow empty + array('allowed', array(), 'foobar@example.com'), + array('valid_complex', array(), "'%$~test@example.com"), + array('invalid', array('EMAIL_INVALID'), 'fööbar@example.com'), + array('taken', array(), 'admin@example.com'), // email does not check taken, should use user_email instead + array('banned', array(), 'banned@example.com'), // email does not check ban, should use user_email instead + ); + } + + /** + * @dataProvider validate_email_data + */ + public function test_validate_email($case, $errors, $email) { $this->set_validation_prerequisites(false); $this->helper->assert_valid_data(array( - 'empty' => array( - array(), - '', - array('email'), - ), - 'allowed' => array( - array(), - 'foobar@example.com', - array('email', 'foobar@example.com'), - ), - 'invalid' => array( - array('EMAIL_INVALID'), - 'fööbar@example.com', - array('email'), - ), - 'valid_complex' => array( - array(), - "'%$~test@example.com", - array('email'), - ), - 'taken' => array( - array('EMAIL_TAKEN'), - 'admin@example.com', - array('email'), - ), - 'banned' => array( - array('EMAIL_BANNED'), - 'banned@example.com', + $case => array( + $errors, + $email, array('email'), ), )); } + public static function validate_email_mx_data() + { + return array( + array('valid', array(), 'foobar@phpbb.com'), + array('no_mx', array('DOMAIN_NO_MX_RECORD'), 'test@does-not-exist.phpbb.com'), + ); + } + /** + * @dataProvider validate_email_mx_data * @group slow */ - public function test_validate_email_mx() + public function test_validate_email_mx($case, $errors, $email) { $this->set_validation_prerequisites(true); $this->helper->assert_valid_data(array( - 'valid' => array( - array(), - 'foobar@phpbb.com', - array('email'), - ), - 'no_mx' => array( - array('DOMAIN_NO_MX_RECORD'), - 'test@does-not-exist.phpbb.com', + $case => array( + $errors, + $email, array('email'), ), )); diff --git a/tests/functions/validate_user_email_test.php b/tests/functions/validate_user_email_test.php new file mode 100644 index 0000000000..951d5794e6 --- /dev/null +++ b/tests/functions/validate_user_email_test.php @@ -0,0 +1,106 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php'; +require_once dirname(__FILE__) . '/../mock/user.php'; +require_once dirname(__FILE__) . '/validate_data_helper.php'; + +class phpbb_functions_validate_user_email_test extends phpbb_database_test_case +{ + protected $db; + protected $user; + protected $helper; + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/validate_email.xml'); + } + + protected function setUp() + { + parent::setUp(); + + $this->db = $this->new_dbal(); + $this->user = new phpbb_mock_user; + $this->helper = new phpbb_functions_validate_data_helper($this); + } + + /** + * Get validation prerequesites + * + * @param bool $check_mx Whether mx records should be checked + */ + protected function set_validation_prerequisites($check_mx) + { + global $config, $db, $user; + + $config['email_check_mx'] = $check_mx; + $db = $this->db; + $user = $this->user; + $user->optionset('banned_users', array('banned@example.com')); + } + + public static function validate_user_email_data() + { + return array( + array('empty', array(), ''), + array('allowed', array(), 'foobar@example.com'), + array('valid_complex', array(), "'%$~test@example.com"), + array('invalid', array('EMAIL_INVALID'), 'fööbar@example.com'), + array('taken', array('EMAIL_TAKEN'), 'admin@example.com'), + array('banned', array('EMAIL_BANNED'), 'banned@example.com'), + ); + } + + /** + * @dataProvider validate_user_email_data + */ + public function test_validate_user_email($case, $errors, $email) + { + $this->set_validation_prerequisites(false); + + $this->helper->assert_valid_data(array( + $case => array( + $errors, + $email, + array('user_email'), + ), + )); + } + + public static function validate_user_email_mx_data() + { + return array( + array('valid', array(), 'foobar@phpbb.com'), + array('no_mx', array('DOMAIN_NO_MX_RECORD'), 'test@does-not-exist.phpbb.com'), + ); + } + + /** + * @dataProvider validate_user_email_mx_data + * @group slow + */ + public function test_validate_user_email_mx($case, $errors, $email) + { + $this->set_validation_prerequisites(true); + + $this->helper->assert_valid_data(array( + $case => array( + $errors, + $email, + array('user_email'), + ), + )); + } +} |