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