more help', array('%url' => url('admin/help/spamspan'))); } return $output; case 'admin/help#spamspan': return t('

The SpamSpan module obfuscates email addresses to help prevent spambots from collecting them. It will produce clickable links if JavaScript is enabled, and will show the email address as example [at] example [dot] com if the browser does not support JavaScript.

To configure the module, select "configure" next to the input format you\'d like to use. Enable "Hide Email Addresses" and submit the form. Then select the "configure" tab to choose relevant options.

', array('%url' => url('admin/filters'))); } } /** * Implementation of hook_filter_tips(). * */ function spamspan_filter_tips($delta, $format, $long = FALSE) { switch ($delta) { case 0: return t('Each email address will be obfuscated in a human readble fashion or (if JavaScript is enabled) replaced with a spamproof clickable link.'); break; } } /** * Implementation of hook_filter(). * */ function spamspan_filter($op, $delta = 0, $format = -1, $text = '') { if ($op == 'list') { return array(0 => t('Hide email addresses')); } switch ($delta) { case 0: switch ($op) { case 'description': return t('Attempt to hide email addresses from spam-bots.'); case 'prepare': return $text; case 'process': return spamspan($text, $format); case 'settings': $form['spamspan_settings'] = array( '#type' => 'fieldset', '#title' => t('SpamSpan email address encoding filter'), '#description' => t('You probably do not need to change any of these settings'), '#collapsible' => true, '#collapsed' => true ); $form['spamspan_settings']['spamspan_userclass_'.$format] = array( '#type' => 'textfield', '#title' => t('Local part class'), '#default_value' => variable_get('spamspan_userclass_'.$format, 'u'), '#required' => TRUE, '#description' => t('The class name of the <span> element enclosing the part of the address before the @') ); $form['spamspan_settings']['spamspan_domainclass_'.$format] = array( '#type' => 'textfield', '#title' => t('Domain part class'), '#default_value' => variable_get('spamspan_domainclass_'.$format, 'd'), '#required' => TRUE, '#description' => t('The class name of the <span> element enclosing the part of the address after the @') ); $form['spamspan_settings']['spamspan_at_'.$format] = array( '#type' => 'textfield', '#title' => t('@ text'), '#default_value' => variable_get('spamspan_at_'.$format, ' [at] '), '#required' => TRUE, '#description' => t('Replace @ with this text when javascript is disabled') ); return $form; } break; } } /** * Implementation of hook_footer(). * */ function spamspan_footer($main = 0) { // Add the javascript to each page drupal_add_js(drupal_get_path("module", "spamspan") . '/spamspan.compressed.js'); // pass necessary variables to the javascript global $spamspan_format; drupal_add_js(array( 'spamspan' => array( 'm' => 'spamspan', 'u' => variable_get('spamspan_userclass_'.$spamspan_format, 'u'), 'd' => variable_get('spamspan_domainclass_'.$spamspan_format, 'd'), 't' => variable_get('spamspan_anchorclass_'.$spamspan_format, 't') ) ), 'setting'); } function spamspan_callback($matches) { // Replace .'s in domain part with [dot] global $spamspan_format; $domain = str_replace("."," [dot] ", $matches[3]); return "$matches[1]$matches[2]" . variable_get('spamspan_at_'.$spamspan_format, ' [at] ') . "$domain"; } function spamspan ($string, $format) { /* We are aiming for code like this: user [at] example [dot] com */ $GLOBALS['spamspan_format'] = $format; $pattern = "!(

|

  • ||[ \n\r\t\(])(?:([-\.\w\+^@]+)@((?:[-\w]+\.)+[A-Z]{2,4}))(?:[.,]?)(?=(?:

    |
  • ||[ \n\r\t\)]))!i"; return preg_replace_callback($pattern, 'spamspan_callback', $string); }