|
|
Forum-Information
Before posting about errors, make sure that the answer cannot already be found
in our FAQ or by searching this forum!
Posting is restricted to registered users ( registering is free and simple!) due to recent spam attacks. When having trouble with this board, contact garvin(-at)s9y(-dot)org.
|
Creating and modifying plugins.
-

gimmel
- Regular
-
- Posts: 118
- Joined: Tue Jul 25, 2006 2:44 pm
- Location: Quickborn/Germany
-
by gimmel » Thu May 05, 2011 4:41 pm
I have some nasty (or perhaps only one with different names) trolls on my blog, so I’m trying to do a anti troll plugin. I’m not sure if this is possible with the existing hooks. It should work like this:
Each commenting user gets a unique id that is saved as cookie. Either the comment db table has to be extended to save this id (is that conform to Serendipity program rules…?) or a second table has to be created to save comment id and the associated unique id. The backend (or admin frontend) comment list should contain „troll“ buttons for each comment. Pressing that button adds the unique id to a blacklist (another table) and the blacklisted user will never see a comment field anymore.
This should work perfectly as long the user allows cookies.
I can set the cookie in the frontend_saveComment hook, but I don’t know the id the comment is saved with. Is there a hook AFTER saving the comment where I can get the comment id? Is it possible to hide the comment field depending on the blacklist (without changing the template)?
It seems to be really easy to make a plugin like this. I’m only missing the right hooks.
-

garvinhicking
- Core Developer
-
- Posts: 28954
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
-
Re: Anti Troll
by garvinhicking » Thu May 05, 2011 4:53 pm
Hi!
I wrote something like that called 'Stalkerbuster' which does something similar. Maybe it can give you a headstart.
I put it into CVS in the additional_plugins/alpha directory. You basically create a stalkerbuster.php file which contains all the uniqe ids of the visitor, and that blocks the person out.
HTH, Garvin
-

gimmel
- Regular
-
- Posts: 118
- Joined: Tue Jul 25, 2006 2:44 pm
- Location: Quickborn/Germany
-
Re: Anti Troll
by gimmel » Fri May 06, 2011 9:41 am
That sounds great! But I can’t reach the additional_plugins directory in your Berlios CVS. 
-

Timbalu
- Regular
-
- Posts: 2567
- Joined: Sun May 02, 2004 3:04 pm
Re: Anti Troll
by Timbalu » Fri May 06, 2011 9:46 am
Regards, Ian
-

gimmel
- Regular
-
- Posts: 118
- Joined: Tue Jul 25, 2006 2:44 pm
- Location: Quickborn/Germany
-
Re: Anti Troll
by gimmel » Fri May 06, 2011 11:52 pm
Thanks a lot, Timbalu.  „Stalkerbuster“ does the same that my „AntiTroll“ plugin does now: generating unique ids and saving them in a cookie. It’s a nice workaround to attach the id to the notification mail, but I would like to have a list of all comments of a specific troll before I decide if I kick him. So I have to to add the unique ids to the comment table. But I don’t think this is possible with the given hooks.
-

garvinhicking
- Core Developer
-
- Posts: 28954
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
-
Re: Anti Troll
by garvinhicking » Sun May 08, 2011 10:51 am
Hi!
You need to use a seperate storage table; I think there shoud be sufficient hooks. Like you could use frontend_saveComment_finish after a comment is inserted, and then associate the cookie id with the commen id in a seperate DB table...?
Regards, Garvin
-

gimmel
- Regular
-
- Posts: 118
- Joined: Tue Jul 25, 2006 2:44 pm
- Location: Quickborn/Germany
-
Re: Anti Troll
by gimmel » Wed May 11, 2011 11:57 pm
Wow, frontend_saveComment_finish sounds good and works perfect. Now I’m tracking the cookie to each comment. The rest seems to be easy. Can you tell me where I can find those hooks like frontend_saveComment_finish? It’s not in your book, it’s not on the hook list. Since I know serendipity (and work on plugins) I’m missing a complete list of all hooks, their needed s9y version and most important their submitted and changable data.
-

garvinhicking
- Core Developer
-
- Posts: 28954
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
-
Re: Anti Troll
by garvinhicking » Thu May 12, 2011 1:20 pm
Hi! Yes, I suppose it's a newer one. Maintaining the list of event hooks is a bit cumbersome; but you can grep for all of those, if you check for "serendipity_plugin_api::hook_event(" you should get a good list. If you find hooks that are not on the s9y hooklist, I'll try to deliver them there - your help would be much appreciated.  Checking which s9y version they were introduced is of course much more time consuming  Regards, Garvin
-

gimmel
- Regular
-
- Posts: 118
- Joined: Tue Jul 25, 2006 2:44 pm
- Location: Quickborn/Germany
-
Re: Anti Troll
by gimmel » Thu May 12, 2011 10:31 pm
There are 97 hooks! Incredible! If someone wants a list, here it is. If I find the time, I will complete it with the submitted values of $addData.
backend_approvecomment backend_auth backend_cache_entries backend_cache_purge backend_category_addNew backend_category_delete backend_category_showForm backend_category_update backend_comments_top backend_configure backend_delete_entry backend_deletecomment backend_directory_create backend_directory_createoptions backend_directory_delete backend_display backend_entry_checkSave backend_entry_iframe backend_entry_presave backend_entry_toolbar_body backend_entry_toolbar_extended backend_entry_updertEntry backend_entryform backend_entryform_smarty backend_frontpage_display backend_header backend_http_request backend_image_add backend_image_addHotlink backend_import_entry backend_login backend_login_page backend_media_check backend_media_delete backend_media_makethumb backend_media_path_exclude_directories backend_media_rename backend_pluginconfig_ backend_pluginlisting_header backend_pluginlisting_header_upgrade backend_plugins_event_header backend_plugins_fetchlist backend_plugins_fetchplugin backend_plugins_new_instance backend_plugins_sidebar_header backend_preview backend_publish backend_save backend_sendmail backend_sidebar_admin backend_sidebar_admin_appearance backend_sidebar_entries backend_sidebar_entries_event_display_ backend_sidebar_entries_event_display_profiles backend_sidebar_entries_images backend_templates_configuration_bottom backend_templates_configuration_none backend_templates_configuration_top backend_templates_fetchtemplate backend_thumbnail_filename_select backend_trackback_check backend_trackbacks backend_updatecomment backend_users_add backend_users_delete backend_users_edit backend_view_comment backend_wysiwyg backend_wysiwyg_finish backend_wysiwyg_nuggets entry_display entry_groupdata external_plugin fetch_images_sql fetchcomments frontend_calendar frontend_configure frontend_display frontend_display:html:per_entry frontend_display:rss-1.0:once frontend_entries_rss frontend_entryproperties frontend_entryproperties_query frontend_fetchentries frontend_fetchentry frontend_generate_plugins frontend_media_showitem frontend_media_showitem_init frontend_rss frontend_saveComment frontend_saveComment_finish frontend_sidebar_plugins frontend_xmlrpc genpage media_getproperties_cached media_showproperties quicksearch_plugin
-

gimmel
- Regular
-
- Posts: 118
- Joined: Tue Jul 25, 2006 2:44 pm
- Location: Quickborn/Germany
-
Re: Anti Troll
by gimmel » Fri May 20, 2011 7:04 pm
Thanks so far for some very good help. The antiTroll plugin grows…
1. Is there a way to add elements to the backend comment list? I would like to add the cookie user token. I see that the spam plugin modifies the entries (author, email, etc.), but does not add more entries.
2. I would like to give the troll comments the status "troll". That way they would not be listed in the frontend, but are kept in the backend to see what blabla a troll has written before. Are there any problems with using a new status value?
3. Is it possible to remove the comment form for recognized trolls? I could generate a 404 like StalkerBuster, but I think it would be cool to simply take away the possibility of commenting.
-

garvinhicking
- Core Developer
-
- Posts: 28954
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
-
Re: Anti Troll
by garvinhicking » Sun May 22, 2011 1:45 pm
Hi! 1: You can add to $eventData['action_more'] in the 'backend_view_comment' event hook! Check include/admin/comments.inc.php to see where it gets outputted. 2: I believe you might get problems in displaying comments, because usually 'pending', 'approved' etc. are hardoced values. But I'd simply try it out, I don'T think something really bad should happen due to that  3: All blocks in the smarty output are variables; so I think if you replace $COMMENTFORM with an empty string in the frontend_footer event hook, this might work. But I'm too short on time to try this out right now  Regards, Garvin
-

garvinhicking
- Core Developer
-
- Posts: 28954
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
-
Re: Anti Troll
by garvinhicking » Sun May 22, 2011 1:46 pm
Hi!
Even better, I think if you use the frontend_display hook and check on troll status, you could simply fake the entry to be "comments closed"...?! ($eventData['allow_comments'] I believe)
Regards, Garvin
-

gimmel
- Regular
-
- Posts: 118
- Joined: Tue Jul 25, 2006 2:44 pm
- Location: Quickborn/Germany
-
Re: Anti Troll
by gimmel » Mon May 23, 2011 12:53 pm
Hi Garvin, thanks for the tips!
The frontend_footer hook does not give access to $COMMENTFORM but in frontend_display. So this both works in frontend_display: Hide the comment form $serendipity['smarty']->assign(array('COMMENTFORM'=>'')); Block comments $eventData['allow_comments'] = 'false';
But, much better: Let the trolls type until their finger are bloody and than show an error after sending the comment. Block comments AFTER sending In frontend_saveComment: $eventData['allow_comments'] = 'false';
(I hate trolls apparently…)
-

gimmel
- Regular
-
- Posts: 118
- Joined: Tue Jul 25, 2006 2:44 pm
- Location: Quickborn/Germany
-
Re: Anti Troll
by gimmel » Fri Jun 24, 2011 4:35 pm
The antitroll plugin is nearly final. I’ve included some functions to have fun with trolls… You can redirect them to appropriate places like here or here. If someone wants to test it: you can download it here. I only have one little problem: deleting the commentform with $serendipity['smarty']->assign(array('COMMENTFORM'=>'')) works as expected on my MAMP sandbox. Unfortunately it does NOT work on my live blog. Perhaps because there’s 1.5.2 an my live blog and 1.5.5 in my sandbox?
-

gimmel
- Regular
-
- Posts: 118
- Joined: Tue Jul 25, 2006 2:44 pm
- Location: Quickborn/Germany
-
Re: Anti Troll
by gimmel » Fri Jun 24, 2011 6:35 pm
Thats’s weird: I installed 1.5.5 on my live blog, too. But I still can’t delete the COMMENTFORM variable. Do you have an idea why this behaviour is different between sandbox and live blog, Garvin?
Return to Plugins
Who is online
Users browsing this forum: No registered users and 3 guests
|