Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

#257 and #266: Apply censoring before validating new posts and topics…

…. Also censor messages in subscription mails.
  • Loading branch information...
commit 7562628fd5c682893d7e6e69c2baeced61abc163 1 parent 8f855ff
Franz Liedke authored February 09, 2011
2  lang/English/post.php
@@ -5,8 +5,10 @@
5 5
 
6 6
 // Post validation stuff (many are similiar to those in edit.php)
7 7
 'No subject'		=>	'Topics must contain a subject.',
  8
+'No subject after censoring'	=>	'Topics must contain a subject. After applying censoring filters, your subject was empty.',
8 9
 'Too long subject'	=>	'Subjects cannot be longer than 70 characters.',
9 10
 'No message'		=>	'You must enter a message.',
  11
+'No message after censoring'	=>	'You must enter a message. After applying censoring filters, your message was empty.',
10 12
 'Too long message'	=>	'Posts cannot be longer that %s bytes.',
11 13
 'All caps subject'	=>	'Subjects cannot contain only capital letters.',
12 14
 'All caps message'	=>	'Posts cannot contain only capital letters.',
28  post.php
@@ -71,9 +71,14 @@
71 71
 	if ($fid)
72 72
 	{
73 73
 		$subject = pun_trim($_POST['req_subject']);
  74
+		
  75
+		if ($pun_config['o_censoring'] == '1')
  76
+			$censored_subject = pun_trim(censor_words($subject));
74 77
 
75 78
 		if ($subject == '')
76 79
 			$errors[] = $lang_post['No subject'];
  80
+		else if ($censored_subject == '')
  81
+			$errors[] = $lang_post['No subject after censoring'];
77 82
 		else if (pun_strlen($subject) > 70)
78 83
 			$errors[] = $lang_post['Too long subject'];
79 84
 		else if ($pun_config['p_subject_all_caps'] == '0' && is_all_uppercase($subject) && !$pun_user['is_admmod'])
@@ -135,8 +140,19 @@
135 140
 		$message = preparse_bbcode($message, $errors);
136 141
 	}
137 142
 
138  
-	if (empty($errors) && $message == '')
139  
-		$errors[] = $lang_post['No message'];
  143
+	if (empty($errors))
  144
+	{
  145
+		if ($message == '')
  146
+			$errors[] = $lang_post['No message'];
  147
+		else if ($pun_config['o_censoring'] == '1')
  148
+		{
  149
+			// Censor message to see if that causes problems
  150
+			$censored_message = pun_trim(censor_words($message));
  151
+			
  152
+			if ($censored_message == '')
  153
+				$errors[] = $lang_post['No message after censoring'];
  154
+		}
  155
+	}
140 156
 
141 157
 	$hide_smilies = isset($_POST['hide_smilies']) ? '1' : '0';
142 158
 	$subscribe = isset($_POST['subscribe']) ? '1' : '0';
@@ -236,7 +252,7 @@
236 252
 								$mail_subject_full = str_replace('<topic_subject>', $cur_posting['subject'], $mail_subject_full);
237 253
 								$mail_message_full = str_replace('<topic_subject>', $cur_posting['subject'], $mail_message_full);
238 254
 								$mail_message_full = str_replace('<replier>', $username, $mail_message_full);
239  
-								$mail_message_full = str_replace('<message>', $message, $mail_message_full);
  255
+								$mail_message_full = str_replace('<message>', $pun_config['o_censoring'] == '1' ? $censored_message : $message, $mail_message_full);
240 256
 								$mail_message_full = str_replace('<post_url>', get_base_url().'/viewtopic.php?pid='.$new_pid.'#p'.$new_pid, $mail_message_full);
241 257
 								$mail_message_full = str_replace('<unsubscribe_url>', get_base_url().'/misc.php?action=unsubscribe&tid='.$tid, $mail_message_full);
242 258
 								$mail_message_full = str_replace('<board_mailer>', $pun_config['o_board_title'].' '.$lang_common['Mailer'], $mail_message_full);
@@ -328,7 +344,7 @@
328 344
 								$mail_message_full = trim(substr($mail_tpl_full, $first_crlf));
329 345
 
330 346
 								$mail_subject = str_replace('<forum_name>', $cur_posting['forum_name'], $mail_subject);
331  
-								$mail_message = str_replace('<topic_subject>', $subject, $mail_message);
  347
+								$mail_message = str_replace('<topic_subject>', $pun_config['o_censoring'] == '1' ? $censored_subject : $subject, $mail_message);
332 348
 								$mail_message = str_replace('<forum_name>', $cur_posting['forum_name'], $mail_message);
333 349
 								$mail_message = str_replace('<poster>', $username, $mail_message);
334 350
 								$mail_message = str_replace('<topic_url>', get_base_url().'/viewtopic.php?id='.$new_tid, $mail_message);
@@ -336,10 +352,10 @@
336 352
 								$mail_message = str_replace('<board_mailer>', $pun_config['o_board_title'].' '.$lang_common['Mailer'], $mail_message);
337 353
 
338 354
 								$mail_subject_full = str_replace('<forum_name>', $cur_posting['forum_name'], $mail_subject_full);
339  
-								$mail_message_full = str_replace('<topic_subject>', $subject, $mail_message_full);
  355
+								$mail_message_full = str_replace('<topic_subject>', $pun_config['o_censoring'] == '1' ? $censored_subject : $subject, $mail_message_full);
340 356
 								$mail_message_full = str_replace('<forum_name>', $cur_posting['forum_name'], $mail_message_full);
341 357
 								$mail_message_full = str_replace('<poster>', $username, $mail_message_full);
342  
-								$mail_message_full = str_replace('<message>', $message, $mail_message_full);
  358
+								$mail_message_full = str_replace('<message>', $pun_config['o_censoring'] == '1' ? $censored_message : $message, $mail_message_full);
343 359
 								$mail_message_full = str_replace('<topic_url>', get_base_url().'/viewtopic.php?id='.$new_tid, $mail_message_full);
344 360
 								$mail_message_full = str_replace('<unsubscribe_url>', get_base_url().'/misc.php?action=unsubscribe&fid='.$cur_posting['id'], $mail_message_full);
345 361
 								$mail_message_full = str_replace('<board_mailer>', $pun_config['o_board_title'].' '.$lang_common['Mailer'], $mail_message_full);

0 notes on commit 7562628

Please sign in to comment.
Something went wrong with that request. Please try again.