From f95e730adf1d77e65cb4c408b49a62e2888b5f64 Mon Sep 17 00:00:00 2001 From: David M Date: Sat, 25 Feb 2006 05:46:52 +0000 Subject: [PATCH] Another one bites the dust :D - Nicer way of cleaning junk in PM export - Added various signature and posting controls :P git-svn-id: file:///svn/phpbb/trunk@5583 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_board.php | 16 +++++++++++++- phpBB/includes/message_parser.php | 26 +++++++++++++++++++++++ phpBB/includes/ucp/ucp_pm_viewfolder.php | 7 +++--- phpBB/install/schemas/schema_data.sql | 6 ++++++ phpBB/language/en/acp/board.php | 27 ++++++++++++++++++++++-- phpBB/language/en/posting.php | 6 +++++- 6 files changed, 81 insertions(+), 7 deletions(-) diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 46d55a5ef5..7586da5a2d 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -97,7 +97,11 @@ class acp_board 'max_poll_options' => array('lang' => 'MAX_POLL_OPTIONS', 'type' => 'text:4:4', 'explain' => false), 'max_post_chars' => array('lang' => 'CHAR_LIMIT', 'type' => 'text:4:6', 'explain' => true), 'max_post_smilies' => array('lang' => 'SMILIES_LIMIT', 'type' => 'text:4:4', 'explain' => true), - 'max_quote_depth' => array('lang' => 'QUOTE_DEPTH_LIMIT', 'type' => 'text:4:4', 'explain' => true) + 'max_post_urls' => array('lang' => 'MAX_POST_URLS', 'type' => 'text:5:4', 'explain' => true), + 'max_post_font_size' => array('lang' => 'MAX_POST_FONT_SIZE', 'type' => 'text:5:4', 'explain' => true), + 'max_quote_depth' => array('lang' => 'QUOTE_DEPTH_LIMIT', 'type' => 'text:4:4', 'explain' => true), + 'max_post_img_width' => array('lang' => 'MAX_POST_IMG_WIDTH', 'type' => 'text:5:4', 'explain' => true), + 'max_post_img_height' => array('lang' => 'MAX_POST_IMG_HEIGHT', 'type' => 'text:5:4', 'explain' => true) ) ); break; @@ -115,6 +119,11 @@ class acp_board 'board_dst' => array('lang' => 'SYSTEM_DST', 'type' => 'radio:yes_no', 'explain' => false), 'allow_html_tags' => array('lang' => 'ALLOWED_TAGS', 'type' => 'text:30:255', 'explain' => true), 'max_sig_chars' => array('lang' => 'MAX_SIG_LENGTH', 'type' => 'text:5:4', 'explain' => true), + 'max_sig_urls' => array('lang' => 'MAX_SIG_URLS', 'type' => 'text:5:4', 'explain' => true), + 'max_sig_font_size' => array('lang' => 'MAX_SIG_FONT_SIZE', 'type' => 'text:5:4', 'explain' => true), + 'max_sig_smilies' => array('lang' => 'MAX_SIG_SMILIES', 'type' => 'text:5:4', 'explain' => true), + 'max_sig_img_width' => array('lang' => 'MAX_SIG_IMG_WIDTH', 'type' => 'text:5:4', 'explain' => true), + 'max_sig_img_height' => array('lang' => 'MAX_SIG_IMG_HEIGHT', 'type' => 'text:5:4', 'explain' => true), 'legend2' => 'GENERAL_OPTIONS', 'allow_privmsg' => array('lang' => 'BOARD_PM', 'type' => 'radio:yes_no', 'explain' => true), @@ -126,6 +135,11 @@ class acp_board 'allow_bbcode' => array('lang' => 'ALLOW_BBCODE', 'type' => 'radio:yes_no', 'explain' => false), 'allow_smilies' => array('lang' => 'ALLOW_SMILIES', 'type' => 'radio:yes_no', 'explain' => false), 'allow_sig' => array('lang' => 'ALLOW_SIG', 'type' => 'radio:yes_no', 'explain' => false), + 'allow_sig_bbcode' => array('lang' => 'ALLOW_SIG_BBCODE', 'type' => 'radio:yes_no', 'explain' => false), + 'allow_sig_img' => array('lang' => 'ALLOW_SIG_IMG', 'type' => 'radio:yes_no', 'explain' => false), + 'allow_sig_flash' => array('lang' => 'ALLOW_SIG_FLASH', 'type' => 'radio:yes_no', 'explain' => false), + 'allow_sig_html' => array('lang' => 'ALLOW_SIG_HTML', 'type' => 'radio:yes_no', 'explain' => false), + 'allow_sig_smilies' => array('lang' => 'ALLOW_SIG_SMILIES', 'type' => 'radio:yes_no', 'explain' => false), 'allow_nocensors' => array('lang' => 'ALLOW_NO_CENSORS', 'type' => 'radio:yes_no', 'explain' => true), 'allow_bookmarks' => array('lang' => 'ALLOW_BOOKMARKS', 'type' => 'radio:yes_no', 'explain' => true) ) diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 292ab36d76..eb37168fdd 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -155,11 +155,18 @@ class bbcode_firstpass extends bbcode function bbcode_size($stx, $in) { + global $user, $config; + if (!$this->check_bbcode('size', $in)) { return ''; } + if ($config['max_' . $this->mode . '_font_size'] && $config['max_' . $this->mode . '_font_size'] < $stx) + { + $this->warn_msg[] = sprintf($user->lang['MAX_FONT_SIZE_EXCEEDED'], $config['max_' . $this->mode . '_font_size']); + } + return '[size=' . $stx . ':' . $this->bbcode_uid . ']' . $in . '[/size:' . $this->bbcode_uid . ']'; } @@ -205,11 +212,26 @@ class bbcode_firstpass extends bbcode function bbcode_img($in) { + global $user, $config; + if (!$this->check_bbcode('img', $in)) { return ''; } + if ($config['max_' . $this->mode . '_img_height'] || $config['max_' . $this->mode . '_img_width']) + { + $stats = getimagesize($in); + if ($config['max_' . $this->mode . '_img_height'] && $config['max_' . $this->mode . '_img_height'] < $stats[1]) + { + $this->warn_msg[] = sprintf($user->lang['MAX_IMG_HEIGHT_EXCEEDED'], $config['max_' . $this->mode . '_img_height']); + } + if ($config['max_' . $this->mode . '_img_width'] && $config['max_' . $this->mode . '_img_width'] < $stats[0]) + { + $this->warn_msg[] = sprintf($user->lang['MAX_IMG_WIDTH_EXCEEDED'], $config['max_' . $this->mode . '_img_width']); + } + } + return '[img:' . $this->bbcode_uid . ']' . $in . '[/img:' . $this->bbcode_uid . ']'; } @@ -689,6 +711,8 @@ class parse_message extends bbcode_firstpass var $allow_flash_bbcode = true; var $allow_quote_bbcode = true; + var $mode; + // Init - give message here or manually function parse_message($message = '') { @@ -708,6 +732,8 @@ class parse_message extends bbcode_firstpass $mode = ($mode != 'post') ? 'sig' : 'post'; + $this->mode = $mode; + $this->allow_img_bbcode = $allow_img_bbcode; $this->allow_flash_bbcode = $allow_flash_bbcode; $this->allow_quote_bbcode = $allow_quote_bbcode; diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php index 173029f0bd..fff1b5928e 100644 --- a/phpBB/includes/ucp/ucp_pm_viewfolder.php +++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php @@ -138,7 +138,8 @@ function view_folder($id, $mode, $folder_id, $folder, $type) if ($submit_export && ($export_type !== 'CSV' || ($delimiter !== '' && $enclosure !== ''))) { - $sql = 'SELECT p.message_text + include_once($phpbb_root_path . 'includes/functions_posting.'.$phpEx); + $sql = 'SELECT p.message_text, p.bbcode_uid FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . ' u WHERE t.user_id = ' . $user->data['user_id'] . " AND p.author_id = u.user_id @@ -149,9 +150,9 @@ function view_folder($id, $mode, $folder_id, $folder, $type) $message_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - $message = preg_replace('#\[(\/?[a-z\*\+\-]+(?:=.*?)?)(?:\:?[0-9a-z]{5,})\]#', '[\1]', $message_row['message_text']); + decode_message($message_row['message_text'], $message_row['bbcode_uid']); - $data[] = array('subject' => censor_text($row['message_subject']), 'from' => $row['username'], 'date' => $user->format_date($row['message_time']), 'to' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? implode(', ', $address_list[$message_id]) : '', 'message' => $message); + $data[] = array('subject' => censor_text($row['message_subject']), 'from' => $row['username'], 'date' => $user->format_date($row['message_time']), 'to' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? implode(', ', $address_list[$message_id]) : '', 'message' => $message_row['message_text']); } else if (!$submit_export || $export_type !== 'CSV') { diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index a8b06d690b..60bec5a97d 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -136,12 +136,18 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_name_chars', ' INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_pass_chars', '30'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_poll_options', '10'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_post_chars', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_post_font_size', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_post_img_height', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_post_img_width', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_post_smilies', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_post_urls', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_quote_depth', '3'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_reg_attempts', '5'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_search_chars', '14'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_sig_chars', '255'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_sig_font_size', '24'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_sig_img_height', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_sig_img_width', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_sig_smilies', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_sig_urls', '5'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('min_name_chars', '3'); diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index 4d12aa2c47..f995670122 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -256,6 +256,14 @@ $lang = array_merge($lang, array( 'SAVE_PASSWORDS_EXPLAIN' => 'Prevents users re-using the specified number of previous passwords or zero to disable.', 'CHAR_LIMIT' => 'Max characters per post', 'CHAR_LIMIT_EXPLAIN' => 'Set to 0 for unlimited characters.', + 'MAX_POST_URLS' => 'Max links per post', + 'MAX_POST_URLS_EXPLAIN' => 'Set to 0 for unlimited links.', + 'MAX_POST_FONT_SIZE' => 'Max font size per post', + 'MAX_POST_FONT_SIZE_EXPLAIN'=> 'Set to 0 for unlimited font size.', + 'MAX_POST_IMG_WIDTH' => 'Max image width per post', + 'MAX_POST_IMG_WIDTH_EXPLAIN'=> 'Set to 0 for unlimited image width.', + 'MAX_POST_IMG_HEIGHT' => 'Max image height per post', + 'MAX_POST_IMG_HEIGHT_EXPLAIN'=> 'Set to 0 for unlimited image height.', 'SMILIES_LIMIT' => 'Max smilies per post', 'SMILIES_LIMIT_EXPLAIN' => 'Set to 0 for unlimited smilies.', 'QUOTE_DEPTH_LIMIT' => 'Max nested quotes per post', @@ -330,6 +338,18 @@ $lang = array_merge($lang, array( 'ALLOW_FORUM_NOTIFY' => 'Allow Forum Watching', 'ALLOW_NAME_CHANGE' => 'Allow Username changes', + 'MAX_SIG_LENGTH' => 'Maximum signature length', + 'MAX_SIG_LENGTH_EXPLAIN' => 'Maximum number of characters in user signatures.', + 'MAX_SIG_URLS' => 'Maximum signature links', + 'MAX_SIG_URLS_EXPLAIN' => 'Maximum number of links in user signatures. Set to 0 for unlimited links.', + 'MAX_SIG_FONT_SIZE' => 'Maximum signature font size', + 'MAX_SIG_FONT_SIZE_EXPLAIN' => 'Maximum font size allowed in user signatures. Set to 0 for unlimited size.', + 'MAX_SIG_SMILIES' => 'Maximum smilies per signature', + 'MAX_SIG_SMILIES_EXPLAIN' => 'Maximum smilies allowed in user signatures. Set to 0 for unlimited size.', + 'MAX_SIG_IMG_WIDTH' => 'Maximum signature image width', + 'MAX_SIG_IMG_WIDTH_EXPLAIN' => 'Maximum width of an image in user signatures. Set to 0 for unlimited size.', + 'MAX_SIG_IMG_HEIGHT' => 'Maximum signature image height', + 'MAX_SIG_IMG_HEIGHT_EXPLAIN'=> 'Maximum height of an image in user signatures. Set to 0 for unlimited size.', 'MIN_RATINGS' => 'Ratings count before karma', 'MIN_RATINGS_EXPLAIN' => 'Number of distinct ratings before users karma is calculated.', 'ALLOW_ATTACHMENTS' => 'Allow Attachments', @@ -340,8 +360,11 @@ $lang = array_merge($lang, array( 'ALLOW_BBCODE' => 'Allow BBCode', 'ALLOW_SMILIES' => 'Allow Smilies', 'ALLOW_SIG' => 'Allow Signatures', - 'MAX_SIG_LENGTH' => 'Maximum signature length', - 'MAX_SIG_LENGTH_EXPLAIN' => 'Maximum number of characters in user signatures.', + 'ALLOW_SIG_IMG' => 'Allow use of IMG BBCode Tag in user signatures', + 'ALLOW_SIG_BBCODE' => 'Allow BBCode in user signatures', + 'ALLOW_SIG_SMILIES' => 'Allow use of smilies in user signatures', + 'ALLOW_SIG_HTML' => 'Allow use of HTML in user signatures', + 'ALLOW_SIG_FLASH' => 'Allow use of FLASH BBCode Tag in user signatures', 'ALLOW_NO_CENSORS' => 'Allow Disable of Censors', 'ALLOW_NO_CENSORS_EXPLAIN' => 'User can disable word censoring.', 'ALLOW_BOOKMARKS' => 'Allow bookmarking topics', diff --git a/phpBB/language/en/posting.php b/phpBB/language/en/posting.php index e54020b8f9..e76831cef1 100644 --- a/phpBB/language/en/posting.php +++ b/phpBB/language/en/posting.php @@ -113,7 +113,11 @@ $lang = array_merge($lang, array( 'LOAD_DRAFT' => 'Load Draft', 'LOAD_DRAFT_EXPLAIN' => 'Here you are able to select the draft you want to continue writing. Your current post will be canceled, all current post contents will be deleted. View, edit and delete drafts within your User Control Panel.', 'LOGIN_EXPLAIN_POST' => 'You need to login in order to post within this forum', - + + 'MAX_FONT_SIZE_EXCEEDED' => 'You may only use fonts up to size %1$d.', + 'MAX_IMG_HEIGHT_EXCEEDED' => 'Your images may only be up to %1$d pixels high.', + 'MAX_IMG_WIDTH_EXCEEDED' => 'Your images may only be up to %1$d pixels wide.', + 'MESSAGE_BODY_EXPLAIN' => 'Enter your message here, it may contain no more than %d characters.', 'MESSAGE_DELETED' => 'Your message has been deleted successfully', 'MORE_SMILIES' => 'View more smilies',