Posts: 36
Threads: 9
Joined: Nov 2010
Well, allowing users to add comments is quite nice feature to bring some interactivity to a website
But if I had to choose between "useless comment" and "no cmment"? I would choose "no comment"
What I mean by "useless cmment" is comments like:
veryyyyyy gooood
tra lal laaaaaaa
So is there any mean to detect such comments and block them, displaying an errror message?
Bad comments for me also includes arabic comments written in latin characters!!!
It looks ugly and less professional for my website
So can I also block any comment written with character other than arabic? (Arabic are like: ا ب ت ج ح خ ....)
Back when I was using phpbb3 forum software, I had the following code to ensure that usernames choosen by new registred members contain only arabic characters plus numerics:
Code:
$regex = '[\p{Arabic}0-9-[\]_+ ]*\p{Arabic}+[\p{Arabic}0-9-[\]_+ ]*';
is it possible to reuse it to acheive my goal?
Posts: 2,894
Threads: 59
Joined: Jun 2010
Yeah it's possible that the script could check the comment against a list of dictionary words and then return a percentage of the matches found, however this might noticeably slow down the processing speed. I will certainly look into it for a future version.
Blocking any comment not entirely written in Arabic should be fairly simple. There would probably need to be a loop which looks at every character of the comment using the regex that you supplied to see whether it's Arabic or not and to set a flag if it's not. Then after the loop has finished it would produce an error if any of the characters were flagged.
Have
you completed
the interview?
Posts: 535
Threads: 31
Joined: Jul 2010
How would you write the name of, say, an English company in Arabic (like Google)? Usually what people do is just type it in English. Wouldn't it be better to check if most of the characters are non-English in that case?
I'm giving you three guesses...
Posts: 36
Threads: 9
Joined: Nov 2010
(07-Jan-2011, 09:42 PM)Steven Wrote: Yeah it's possible that the script could check the comment against a list of dictionary words and then return a percentage of the matches found
Yes, It would be a handy feature. Admins can define bad words. This will help fight spam
In the followin coment: "tra lal laaaaaaa", maybe we need only to block repetitive characters
(07-Jan-2011, 09:42 PM)Steven Wrote: Blocking any comment not entirely written in Arabic should be fairly simple.
Well, you answer make me realise that the logic is more complicated !!! In fact, I want only to ensure that there is at least ONE arabic characters, because based on my own experience, users never mix alphabets !!! they use either arabic or latin. So a chack for at least ONE arabic characters would me than sufficient
Posts: 36
Threads: 9
Joined: Nov 2010
(07-Jan-2011, 10:46 PM)Static Wrote: Wouldn't it be better to check if most of the characters are non-English in that case?
Yes, This is exactely what I mean: check if
most...
Posts: 2,894
Threads: 59
Joined: Jun 2010
This function, designed for v1.2, makes sure that there is at least one Arabic character:
PHP Code:
<?php
function comment_check_arabic ($comment) { //checks whether comment is arabic
if (!preg_match("/\p{Arabic}/u", $comment)) {
error("The comment entered is not Arabic. Please write it in Arabic.");
}
} //end of comment-check-arabic function
Add the above function inside comments/includes/functions/processor.php
Then in comments/includes/app/processor.php, find this part:
PHP Code:
<?php
if ($approve_images) {
comment_detect_image($comment); //detect images in comment
}
And add this on the line below it:
PHP Code:
<?php
comment_check_arabic($comment);