b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (Version 1.8) [ class tree: plugins ] [ index: plugins ] [ all elements ]

Class: dnsbl_antispam_plugin

Source Location: /blogs/plugins/_dnsbl_antispam.plugin.php

Class dnsbl_antispam_plugin

Class Overview

This plugin provides the event SessionLoaded() and checks the remote IP against a list of DNS Blacklists.

It allows the user to whitelist her/himself through the plugin interface itself, by optionally using a plugin that provides Plugin::CaptchaValidated() and Plugin::CaptchaPayload() events. See validate_my_deps().

Located in /blogs/plugins/_dnsbl_antispam.plugin.php [line 40]

Plugin
   |
   --dnsbl_antispam_plugin
Author(s):
Information Tags:
Todo:  Option to only block Feedback-posting events

Properties

Methods

[ Top ]
Inherited Properties, Constants, and Methods
Inherited Properties Inherited Methods Inherited Constants

Inherited From Plugin

Plugin::$apply_rendering
Plugin::$help_url
Plugin::$long_desc
Plugin::$number_of_installs
Plugin::$short_desc

Inherited From Plugin

Plugin::Plugin()
Constructor.
Plugin::AdminAfterMenuInit()
Event handler: Gets invoked in /admin/_header.php for every backoffice page after the menu structure is build. You could use the $AdminUI object to modify it.
Plugin::AdminAfterPageFooter()
Event handler: Called right after displaying the admin page footer.
Plugin::AdminBeforeItemEditCreate()
Event handler: Called before a new item gets created (in the backoffice).
Plugin::AdminBeforeItemEditUpdate()
Event handler: Called before an existing item gets updated (in the backoffice).
Plugin::AdminBeginPayload()
Event handler: Gets invoked before the main payload in the backoffice.
Plugin::AdminDisplayEditorButton()
Event handler: Called when displaying editor buttons.
Plugin::AdminDisplayItemFormFieldset()
Event handler: Called at the end of the "Edit item" form:
Plugin::AdminDisplayToolbar()
Event handler: Called when displaying editor toolbars.
Plugin::AdminEndHtmlHead()
Event handler: Called when ending the admin html head section.
Plugin::AdminTabAction()
Event handler: Method that gets invoked when our tab is selected.
Plugin::AdminTabPayload()
Event handler: Gets invoked when our tab is selected and should get displayed.
Plugin::AdminToolAction()
Event handler: Called when handling actions for the "Tools" menu.
Plugin::AdminToolPayload()
Event handler: Called when displaying the block in the "Tools" menu.
Plugin::AfterCommentDelete()
Event handler: called at the end of deleting a comment from the database.
Plugin::AfterCommentFormInsert()
Event handler: Called when a comment form has been processed and the comment got inserted into DB.
Plugin::AfterCommentInsert()
Event handler: called at the end of inserting a comment into the database, which means it has been created.
Plugin::AfterCommentUpdate()
Event handler: called at the end of updating a comment in the database, which means that it has changed.
Plugin::AfterInstall()
Event handler: Called after the plugin has been installed.
Plugin::AfterItemDelete()
Event handler: called at the end of deleting an item/post from the database.
Plugin::AfterItemInsert()
Event handler: called at the end of inserting a item/post into the database, which means it has been created.
Plugin::AfterItemUpdate()
Event handler: called at the end of updating an item/post in the database, which means that it has been changed.
Plugin::AfterLoginAnonymousUser()
Event handler: Called at the end of the login procedure, if the user is anonymous ($current_User NOT set).
Plugin::AfterLoginRegisteredUser()
Event handler: Called at the end of the login procedure, if the $current_User is set and the user is therefor registered.
Plugin::AfterUserDelete()
Event handler: called at the end of deleting an user from the database.
Plugin::AfterUserInsert()
Event handler: called at the end of inserting an user account into the database, which means it has been created.
Plugin::AfterUserRegistration()
Event handler: Called when a new user has registered and got created.
Plugin::AfterUserUpdate()
Event handler: called at the end of updating an user account in the database, which means that it has been changed.
Plugin::AlternateAuthentication()
Event handler: called at the end of the login process, if the user did not try to login (by sending "login" and "pwd"), the session has no user attached or only "login" is given.
Plugin::AppendItemPreviewTransact()
Event handler: called when instantiating an Item for preview.
Plugin::AppendPluginRegister()
Event handler: Called at the event of registering/instantiating the Plugin (in Plugins::register()).
Plugin::AppendUserRegistrTransact()
Event handler: Called when a new user has registered, at the end of the DB transaction that created this user.
Plugin::are_events_available()
Check if the requested list of events is provided by any or one plugin.
Plugin::BeforeBlogDisplay()
Event handler: Called before a blog gets displayed (in _blog_main.inc.php).
Plugin::BeforeCommentFormInsert()
Event handler: Called before a comment gets inserted through the public comment form.
Plugin::BeforeDisable()
Event handler: Your plugin gets notified here, just before it gets disabled.
Plugin::BeforeEnable()
Event handler: Called when the admin tries to enable the plugin, changes its configuration/settings and after installation.
Plugin::BeforeInstall()
Event handler: Called before the plugin is going to be installed.
Plugin::BeforeTrackbackInsert()
Event handler: called before a trackback gets recorded.
Plugin::BeforeUninstall()
Event handler: Called before the plugin is going to be un-installed.
Plugin::BeforeUninstallPayload()
Event handler: Gets invoked to display the payload before uninstalling the plugin.
Plugin::CacheIsCollectingContent()
Event handler: gets asked for if we are generating cached content.
Plugin::CacheObjects()
Event handler: called to cache object data.
Plugin::CachePageContent()
Event handler: called to cache page content (get cached content or request caching).
Plugin::CaptchaPayload()
Event handler: general event to inject payload for a captcha test.
Plugin::CaptchaValidated()
Event handler: general event to validate a captcha which payload was added through CaptchaPayload().
Plugin::CaptchaValidatedCleanup()
Event handler: general event to be called after an action has been taken, which involved CaptchaPayload() and CaptchaValidated().
Plugin::code()
Template function: display plugin code
Plugin::debug_log()
Log a debug message.
Plugin::disable_event()
Disable an event.
Plugin::DisplayCommentFormButton()
Event handler: Called in the submit button section of the frontend comment form.
Plugin::DisplayCommentFormFieldset()
Event handler: Called at the end of the frontend comment form.
Plugin::DisplayItemAllFormats()
Event handler: Called when displaying an item/post's content.
Plugin::DisplayLoginFormFieldset()
Event handler: Called at the end of the "Login" form.
Plugin::DisplayMessageFormButton()
Event handler: Called in the submit button section of the frontend message form.
Plugin::DisplayMessageFormFieldset()
Event handler: Called at the end of the frontend message form, which allows to send an email to a user/commentator.
Plugin::DisplayRegisterFormFieldset()
Event handler: Called at the end of the "Register as new user" form.
Plugin::DisplayValidateAccountFormFieldset()
Event handler: Called at the end of the "Validate user account" form, which gets invoked if newusers_mustvalidate is enabled and the user has not been validated yet.
Plugin::enable_event()
Enable an event.
Plugin::FilterCommentAuthor()
Event handler: called to filter the comment's author name (blog name for trackbacks)
Plugin::FilterCommentAuthorUrl()
Event handler: called to filter the comment's author URL
Plugin::FilterCommentContent()
Event handler: called to filter the comment's content
Plugin::FilterIpAddress()
Event handler: Called when an IP address gets displayed, typically in a protected area or for a privileged user, e.g. in the backoffice statistics menu.
Plugin::forget_events()
Call this to unregister all your events for the current request.
Plugin::GetDbLayout()
This method should return your DB schema, consisting of a list of CREATE TABLE queries.
Plugin::GetDefaultSettings()
Define here default settings that are then available in the backoffice.
Plugin::GetDefaultUserSettings()
Define here default user settings that are then available in the backoffice.
Plugin::GetDependencies()
Get the list of dependencies that the plugin has.
Plugin::GetHtsrvMethods()
Override this method to define methods/functions that you want to make accessible through /htsrv/call_plugin.php, which allows you to call those methods by HTTP request.
Plugin::GetSpamKarmaForComment()
Event handler: Called to ask the plugin for the spam karma of a comment.
Plugin::get_class_id()
Get a string, unqiue for the plugin, usable in HTML form elements.
Plugin::get_edit_settings_link()
Get a link to edit the Plugin's settings (if the user has permission).
Plugin::get_help_file()
Get the help file for a Plugin ID. README.LOCALE.html will take precedence above the general (english) README.html.
Plugin::get_help_link()
Get a link to a help page (with icon).
Plugin::get_htsrv_url()
Get the URL to call a plugin method through http. This links to the /htsrv/call_plugin.php file.
Plugin::get_plugin_url()
Get the absolute URL to the plugin's directory (trailing slash included).
Plugin::get_README_link()
Display a link to open the Plugin's README.html file in a JS popup, if available.
Plugin::get_sql_table()
Get canonical name for database tables a plugin uses, by adding an unique prefix for your plugin instance.
Plugin::ItemCanComment()
Event handler: the plugin gets asked if an item can receive feedback/comments.
Plugin::ItemViewsIncreased()
Event handler: Called when the view counter of an item got increased.
Plugin::LoginAttempt()
Event handler: called when a user attemps to login.
Plugin::Logout()
Event handler: called when a user logs out.
Plugin::long_desc()
Template function: display long description for plug in
Plugin::MessageFormSent()
Event handler: Called when a message form has been submitted.
Plugin::MessageFormSentCleanup()
Event handler: Called after a message has been sent through the public email form.
Plugin::msg()
A simple wrapper around the $Messages object with a default catgory of 'note'.
Plugin::name()
Template function: Get displayable plugin name.
Plugin::PluginSettingsEditAction()
Event handler: Called as action before displaying the "Edit plugin" form, which includes the display of the Plugin::Settings.
Plugin::PluginSettingsEditDisplayAfter()
Event handler: Called after the form to edit the Plugin::Settings has been displayed.
Plugin::PluginSettingsUpdateAction()
Event handler: Called as action just before updating the Plugin::Settings.
Plugin::PluginSettingsValidateSet()
Event handler: Called before displaying or setting a plugin's setting in the backoffice.
Plugin::PluginUserSettingsEditAction()
Event handler: Called as action before displaying the "Edit user" form, which includes the display of the Plugin::UserSettings.
Plugin::PluginUserSettingsEditDisplayAfter()
Event handler: Called after the form to edit the Plugin::UserSettings has been displayed.
Plugin::PluginUserSettingsUpdateAction()
Event handler: Called as action just before updating the Plugin::UserSettings.
Plugin::PluginUserSettingsValidateSet()
Event handler: Called before displaying or setting a plugin's user setting in the backoffice.
Plugin::PluginVersionChanged()
Event handler: Called when we detect a version change (in Plugins::register()).
Plugin::PrependItemInsertTransact()
Event handler: called at the beginning of inserting an item/post in the database.
Plugin::PrependItemUpdateTransact()
Event handler: called at the beginning of updating an item/post in the database.
Plugin::RegisterFormSent()
Event handler: Called when a "Register as new user" form has been submitted.
Plugin::register_menu_entry()
Register a tab (sub-menu) for the backoffice Tools menus.
Plugin::RenderItem()
Event handler: Called when rendering item/post contents other than XML or HTML.
Plugin::RenderItemAsHtml()
Event handler: Called when rendering item/post contents as HTML.
Plugin::RenderItemAsXml()
Event handler: Called when rendering item/post contents as XML.
Plugin::SessionLoaded()
Event handler: Called after initializing plugins, DB, Settings, Hit, .. but quite early.
Plugin::session_delete()
Delete a value from the session data, using a unique prefix to the Plugin.
Plugin::session_get()
Get a data value for the session, using a unique prefix to the Plugin.
Plugin::session_set()
Set a data value for the session.
Plugin::set_param()
Set param value.
Plugin::set_status()
Set the status of the plugin.
Plugin::short_desc()
Template function: display short description for plug in
Plugin::SkinBeginHtmlHead()
Event handler: Called at the beginning of the skin's HTML HEAD section.
Plugin::stop_propagation()
Stop propagation of the event to next plugins (with lower priority) in events that get triggered for a batch of Plugins.
Plugin::T_()
Translate a given string, in the Plugin's context.
Plugin::ValidateAccountFormSent()
Event handler: Called when a "Validate user account" form has been submitted.

[ Top ]
Property Summary
mixed   $author  
mixed   $code  
mixed   $name  
mixed   $priority  
mixed   $version  

[ Top ]
Method Summary
dnsbl_antispam_plugin   dnsbl_antispam_plugin()   Constructor
void   AdminAfterMenuInit()   Register a tools tab.
void   AdminTabAction()   Method that gets invoked when we're selected in the tools menu.
void   AdminTabPayload()   Display our tool tab with query action and statistics if enabled.
void   AfterInstall()   Check dependency on Captcha plugin, add note in case it's missing and disable the setting.
void   AppendPluginRegister()   Get $use_whitelisting property, if not set before (e.g. in Install()).
false|string   check_dnsbl_ip()   Check a given IP on a given blacklist.
void   display_error_page()   Display error page that may allow whitelisting the Session.
void   FilterIpAddress()   We wrap IP addresses with a link that points to the IP (with "http://" prefixed) and provide an onclick event to query the address through the browser.
void   GetDbLayout()   A table for logging statistics.
array   GetDefaultSettings()   Get the default settings of the plugin.
void   GetDependencies()   We recommend a Captcha plugin.
false|string|array   is_listed()   Check if an IP is blacklisted.
void   PluginSettingsValidateSet()   Check "use_whitelisting" activation.
boolean   SessionLoaded()   Plugin's main action hook.
boolean   update_stats()   Update our statistics.
string|true   validate_my_deps()   Internal method to check dependencies on Captcha plugin.

[ Top ]
Properties
mixed   $author = 'The b2evo Group' [line 46]

Redefinition of:
Plugin::$author
Plugin author.

[ Top ]
mixed   $code = 'evo_dnsbl' [line 43]

Redefinition of:
Plugin::$code
Globally unique code for this plugin functionality. 32 chars. MUST BE SET.

[ Top ]
mixed   $name = 'DNSBL Antispam' [line 42]

Redefinition of:
Plugin::$name
Default plugin name as it will appear in lists.

[ Top ]
mixed   $priority = 40 [line 44]

Redefinition of:
Plugin::$priority
Default priority.

[ Top ]
mixed   $version = '1.8' [line 45]

Redefinition of:
Plugin::$version
Plugin version number (max 42 chars, so obscure CVS Revision keywords get handled).

[ Top ]
Methods
Constructor dnsbl_antispam_plugin  [line 52]

  dnsbl_antispam_plugin dnsbl_antispam_plugin( )

Constructor



[ Top ]
AdminAfterMenuInit  [line 161]

  void AdminAfterMenuInit( )

Register a tools tab.



Redefinition of:
Plugin::AdminAfterMenuInit()
Event handler: Gets invoked in /admin/_header.php for every backoffice page after the menu structure is build. You could use the $AdminUI object to modify it.

[ Top ]
AdminTabAction  [line 172]

  void AdminTabAction( )

Method that gets invoked when we're selected in the tools menu.

Catch params and do actions.



Redefinition of:
Plugin::AdminTabAction()
Event handler: Method that gets invoked when our tab is selected.

[ Top ]
AdminTabPayload  [line 243]

  void AdminTabPayload( )

Display our tool tab with query action and statistics if enabled.



Redefinition of:
Plugin::AdminTabPayload()
Event handler: Gets invoked when our tab is selected and should get displayed.

[ Top ]
AfterInstall  [line 361]

  void AfterInstall( )

Check dependency on Captcha plugin, add note in case it's missing and disable the setting.



Redefinition of:
Plugin::AfterInstall()
Event handler: Called after the plugin has been installed.

[ Top ]
AppendPluginRegister  [line 376]

  void AppendPluginRegister( )

Get $use_whitelisting property, if not set before (e.g. in Install()).



Redefinition of:
Plugin::AppendPluginRegister()
Event handler: Called at the event of registering/instantiating the Plugin (in Plugins::register()).

[ Top ]
check_dnsbl_ip  [line 569]

  false|string check_dnsbl_ip( $ip, $blacklist  )

Check a given IP on a given blacklist.

Parameters:
   $ip: 
   $blacklist: 

API Tags:
Return:  false if not listed, the resulting string otherwise.


[ Top ]
display_error_page  [line 589]

  void display_error_page( string $error_ip_blocked  )

Display error page that may allow whitelisting the Session.

Parameters:
string   $error_ip_blocked:  Additional error message.


[ Top ]
FilterIpAddress  [line 459]

  void FilterIpAddress( &$params  )

We wrap IP addresses with a link that points to the IP (with "http://" prefixed) and provide an onclick event to query the address through the browser.

Parameters:
   &$params: 


Redefinition of:
Plugin::FilterIpAddress()
Event handler: Called when an IP address gets displayed, typically in a protected area or for a privileged user, e.g. in the backoffice statistics menu.

[ Top ]
GetDbLayout  [line 138]

  void GetDbLayout( )

A table for logging statistics.



Redefinition of:
Plugin::GetDbLayout()
This method should return your DB schema, consisting of a list of CREATE TABLE queries.

[ Top ]
GetDefaultSettings  [line 64]

  array GetDefaultSettings( )

Get the default settings of the plugin.



Redefinition of:
Plugin::GetDefaultSettings()
Define here default settings that are then available in the backoffice.

[ Top ]
GetDependencies  [line 125]

  void GetDependencies( )

We recommend a Captcha plugin.



Redefinition of:
Plugin::GetDependencies()
Get the list of dependencies that the plugin has.

[ Top ]
is_listed  [line 481]

  false|string|array is_listed( string $ip, [boolean $check_all = false]  )

Check if an IP is blacklisted.

Parameters:
string   $ip:  IP address / host name
boolean   $check_all:  Check all given lists, or return error on first match?

API Tags:
Return:  false: IP is ok string: The value of the lookup when blacklisted ("blacklist: reason") array: of strings if $check_all


[ Top ]
PluginSettingsValidateSet  [line 346]

  void PluginSettingsValidateSet( &$params  )

Check "use_whitelisting" activation.

Parameters:
   &$params: 


Redefinition of:
Plugin::PluginSettingsValidateSet()
Event handler: Called before displaying or setting a plugin's setting in the backoffice.

[ Top ]
SessionLoaded  [line 395]

  boolean SessionLoaded( )

Plugin's main action hook.

It checks if the remote IP is in the list of DNS Blacklists and dies with an error page then, allowing the user to whitelist her/himself for the session if a plugin is installed for it.



Redefinition of:
Plugin::SessionLoaded()
Event handler: Called after initializing plugins, DB, Settings, Hit, .. but quite early.

[ Top ]
update_stats  [line 643]

  boolean update_stats( string $type, [ $data = NULL], [ $doit = false]  )

Update our statistics.

We call ourself here as shutdown_function because we want $Hit::ID.

Parameters:
string   $type:  Type ('blocked', 'not_blocked', 'whitelisted')
   $data: 
   $doit: 


[ Top ]
validate_my_deps  [line 674]

  string|true validate_my_deps( )

Internal method to check dependencies on Captcha plugin.



[ Top ]

Documentation generated on Tue, 18 Dec 2007 23:12:30 +0100 by phpDocumentor 1.4.0