jcomments, where is this precious feature?

This forum is for general questions about extensions for Joomla! 3.x.

Moderators: pe7er, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
Michael REMY
Joomla! Apprentice
Joomla! Apprentice
Posts: 46
Joined: Thu Feb 25, 2010 9:32 am

jcomments, where is this precious feature?

Post by Michael REMY » Sat Jun 06, 2015 7:31 am

hi,

i choose to desable the kapatcha because neo-internet people (old one, neophites) doesn't know about capatcha and can't manage to post any comment.

i just need a way to block at client-side (so not even server-side) the comment which could contain any banned-word.

Jcomments already have a system of filtered banned-word but it works only server-side.

i just need it to work on client-side in this little case :
if the comment contains a forbiden-word, then DO NOT allow the http POST (like by hiding the html post buton!) , neither send me the email alert, neither the sore in database this comment.

best way would be to have an javascript alert box client-side saing "hey guy, you write a bad word, i won't let you post it, sorrry" and hide the button to send the post.

i search anywhere such an extension/plugin to jcomments and cna't find it.

it is very very very easy to program-develop it (php) that i don't understand why there is no such thing.

As i said, the banned-word system is already in, but server side.

it must beeasy to use it to directly block the post client-side....

In the otherway, maybe on of you can tell me in which file i can insert a javascript code to do that with a list of 3 word i wish to forbid.

thank you for any suggestion, any will be welcomed.

Michael REMY
Joomla! Apprentice
Joomla! Apprentice
Posts: 46
Joined: Thu Feb 25, 2010 9:32 am

Re: jcomments, where is this precious feature?

Post by Michael REMY » Sat Jun 06, 2015 8:46 am

well, that PHP code was so easy i did it myself.

i will post the change to joomlatune once they will answer me.

in fact this feature (block comment client-side) already exist for test&prevent bad user name (like people who autonamed themsleves like 'admin').

the ajax client-system-side already block visitor for posting comment with such abused names, so i improved it.
as you should not use bad name, you should neither use banned-words neither in the name.

Michael REMY
Joomla! Apprentice
Joomla! Apprentice
Posts: 46
Joined: Thu Feb 25, 2010 9:32 am

jcomments client-side badwords blocking system

Post by Michael REMY » Sat Jun 06, 2015 8:55 am

so, here my jcomments improvement to have a client-side badword blocking system.
and also the improvement into the check name (to use the badwords content).
i test it myslef, please have a self test too yourself, i am not superman.
i will contact joomlatune to provide it too.

now, i can peacefully desable kaptacha and have my own badword list for spam on the client-side.

please make a backup before apply my solution.
it is for com_jcomments_v3.0.5 release, tested on joomla 3.3.6 and 2.5.19 release.

1. in the file /component/com_jcomments/classes/security.php
just add this function (after checkIsForbiddenUsername by example)

Code: Select all

public static function checkIsForbiddenWords($str)
	{			
		$names = JCommentsFactory::getConfig()->get('badwords');		

		if (!empty($names) && !empty($str)) {
			$str = trim(strtolower($str));

			$names = strtolower(preg_replace("#,+#", ',', preg_replace("#[\n|\r]+#", ',', $names)));
			$names = explode(",", $names);

			foreach ($names as $name) {
				if (trim((string)$name) == $str) {
					return 1;
				}
			}
		}
		

		return 0;
	}
2. again, in the file /component/com_jcomments/classes/security.php
add this line just under that one in L53 :
$names = JCommentsFactory::getConfig()->get('forbidden_names');

Code: Select all

$names.=",".JCommentsFactory::getConfig()->get('badwords');		
after this bold insert, you must have this sample lines like this :
public static function checkIsForbiddenUsername($str)
{
$names = JCommentsFactory::getConfig()->get('forbidden_names');
$names.=",".JCommentsFactory::getConfig()->get('badwords');

if (!empty($names) && !empty($str)) {
this add will provide the badword test in the user name.

3. in the file /component/com_jcomments/comments.ajax.php
insert this BOLD part :
} else if (JCommentsSecurity::checkIsForbiddenUsername($values['name']) == 1) {
self::showErrorMessage(JText::_('ERROR_FORBIDDEN_NAME'), 'name');
} else if (JCommentsSecurity::checkIsForbiddenWords($values['comment']) == 1) {
self::showErrorMessage(JText::_('ERROR_FORBIDDEN_WORD'), 'name');

} else if (preg_match('/[\"\'\[\]\=\<\>\(\)\;]+/', $values['name'])) {
what is bold , is that, it will be in L188 :

Code: Select all

} else if (JCommentsSecurity::checkIsForbiddenWords($values['comment']) == 1) {
					self::showErrorMessage(JText::_('ERROR_FORBIDDEN_WORD'), 'name');
4. in the file /language/e,-GB/en-GB.com_jcomments.ini
add this line:

Code: Select all

ERROR_FORBIDDEN_WORD="Specified comment contains a forbidden word.!"
5. in this other file too /components/com_jcomments/languages/en-GB.com_jcomments.ini
add this line:

Code: Select all

ERROR_FORBIDDEN_WORD="Specified comment contains a forbidden word.!"
also, don't forget to override or add you own language line too in the right language file.

have fun !
Jomments is really the best one with this feature for me !

User avatar
phidias81
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 247
Joined: Thu Dec 15, 2011 11:44 pm
Contact:

Re: jcomments, where is this precious feature?

Post by phidias81 » Sat Jun 06, 2015 11:36 pm

Hey, thank you for the help, but in my case it wouldn't be helpful, just a few words wouldn't be able to stop spammers in my case.
But you say that you will disable the built-in captcha. How can you do that?
Because this is the real problem for me, after disabling it, I can enable a different captcha
At Nomad Travellers you find my travel stories, unusual places and amazing photos: visit my new website and travel from your chair! Make yourself comfortable and start your Nomad Travel! http://www.nomadtravellers.com/

Michael REMY
Joomla! Apprentice
Joomla! Apprentice
Posts: 46
Joined: Thu Feb 25, 2010 9:32 am

Re: jcomments, where is this precious feature?

Post by Michael REMY » Sun Jun 07, 2015 7:38 am

phidias81 wrote:Hey, thank you for the help, but in my case it wouldn't be helpful, just a few words wouldn't be able to stop spammers in my case.
But you say that you will disable the built-in captcha. How can you do that?
Because this is the real problem for me, after disabling it, I can enable a different captcha
just go into settings, then into "permissions" and just uncheck the "Enable CAPTCHA" for each profil you don't want it (public,manager, adminstrator...) from the left tab.

User avatar
phidias81
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 247
Joined: Thu Dec 15, 2011 11:44 pm
Contact:

Re: jcomments, where is this precious feature?

Post by phidias81 » Wed Jun 10, 2015 1:39 am

it actually worked, I don't know why there where so many reports it didn't, thank you!
At Nomad Travellers you find my travel stories, unusual places and amazing photos: visit my new website and travel from your chair! Make yourself comfortable and start your Nomad Travel! http://www.nomadtravellers.com/


Locked

Return to “Extensions for Joomla! 3.x”