Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Not Solved Disallow specific characters in thread title.
#1
Not Solved
I want to disallow specific characters in thread titles. Since some of the members add some weird ASCII characters, I want to make my thread titles accept only characters in range of 0-127. Anything beyond/below that gets removed automatically.

Anyone can help?
#2
Not Solved
Anyone can help?
#3
Not Solved
Anyone can help?
#4
Not Solved
Up.. need help1
#5
Not Solved
First, you would have to clearly define which characters you want to keep. Letters, numbers, punctuation, brackets, etc.

Once you have that defined, the easiest approach is to add code to /inc/datahandlers/post.php. I think adding to the verify_subject function would do the trick. Here's an example that strips out anything that is not letters, numbers, dashes or spaces.

	function verify_subject()
	{
		global $db;
		$post = &$this->data;
		$subject = &$post['subject'];
		$subject = trim_blank_chrs($subject);

		//BEGIN MOD
		$subject= preg_replace('/[^A-Za-z0-9-\s]/', '', $subject);  //change regex to acceptable characters!
		//END MOD

No warning is given and the characters are just stripped out. You could display an error if bad characters were included instead, but it sounds like you just want to strip them.

Make sure you test this first.
#6
Not Solved
I'm not sure if you want to replace accented letters (such as á) with their base letter (a).
#7
Not Solved
(2013-06-14, 08:39 PM)laie_techie Wrote: I'm not sure if you want to replace accented letters (such as á) with their base letter (a).

I want them to disappear completely. Smile Only normal letters, numbers allowed and specials <127 ASCII code (They are: ) ( , - + . / % " ! $ & ^ { | } ~ _ \ [ ] ` etc.)

I'll try buzzle's code soon. I don't know PHP myself though, so I can't edit it.


Forum Jump:


Users browsing this thread: 1 Guest(s)