plugins/SampleSpamcheck.php
author Dan
Mon, 26 Jan 2009 11:03:29 -0500
changeset 0 4d846a385063
permissions -rw-r--r--
First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
     1
<?php
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
     2
/**!info**
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
     3
{
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
     4
  "Plugin Name"  : "Sample spam check",
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
     5
  "Plugin URI"   : "http://enanocms.org/plugin/sample-spamcheck",
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
     6
  "Description"  : "Sample spam check plugin. Very basic, and designed only to demonstrate how to develop spam filtering plugins to developers.",
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
     7
  "Author"       : "Dan Fuhry",
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
     8
  "Version"      : "1.0",
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
     9
  "Author URI"   : "http://enanocms.org/"
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    10
}
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    11
**!*/
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    12
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    13
// Attach to the spam_check hook
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    14
$plugins->attachHook('spam_check', 'sample_spam_check($string, $name, $email, $url, $ip);');
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    15
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    16
function sample_spam_check(&$string, &$name, &$email, &$url, &$ip)
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    17
{
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    18
  // Define our word list
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    19
  $words = array('boob', 'titty', 'teenage', 'viagra');
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    20
  foreach ( $words as $word )
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    21
  {
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    22
    if ( stristr($string, $word) )
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    23
      return false;
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    24
  }
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    25
  // This name always means trouble.
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    26
  if ( $name == 'Pojo' )
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    27
    return false;
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    28
  // Block hotmail e-mail addresses
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    29
  if ( preg_match('/@hotmail\.com$/', $email) )
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    30
    return false;
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    31
  // Check URL for bad words
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    32
  foreach ( $words as $word )
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    33
  {
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    34
    if ( stristr($url, $word) )
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    35
      return false;
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    36
  }
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    37
  // block IPs
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    38
  if ( $ip == '127.0.1.1') 
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    39
    return false;
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    40
  
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    41
  // Always return true if all checks pass!
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    42
  return true;
4d846a385063 First (and probably only) commit. This plugin is intended only for developers to see how to do spam filtering.
Dan
parents:
diff changeset
    43
}