G2A Many GEOs
SHARE
TWEET

Phorum 5.2 Stopforumspam module 0.2 patch

skyepn Dec 20th, 2011 144 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff -u stopforumspam/defaults.php /tmp/stopforumspam/defaults.php
  2. --- stopforumspam/defaults.php  2011-12-19 11:54:16.000000000 -0800
  3. +++ /tmp/stopforumspam/defaults.php     2011-11-28 09:35:41.000000000 -0800
  4. @@ -9,13 +9,11 @@
  5.  // The default settings for the Stopforumspam  module.
  6.  $mod_stopforumspam_defaults = array(
  7.     'block_action' => 'unapprove',
  8. -   'check_ip' => 1,
  9. +   'check_ip' => 0,
  10.      'check_username' => 0,
  11.      'check_email' => 1,
  12.      'log_events' => 1,
  13.      'apikey' => '0000',
  14. -    'force_generic' => 0,
  15. -    'freq_min' => 1,
  16.  );
  17.  
  18.  foreach ($mod_stopforumspam_defaults as $key => $val)
  19. diff -u stopforumspam/info.txt /tmp/stopforumspam/info.txt
  20. --- stopforumspam/info.txt      2011-12-15 20:04:58.000000000 -0800
  21. +++ /tmp/stopforumspam/info.txt 2011-11-28 09:35:41.000000000 -0800
  22. @@ -1,8 +1,8 @@
  23. -title: Stop Forum Spam
  24. -desc: This module uses stopforumspam.com to check newly registered users against their database of known spammers
  25. -version: 0.2
  26. -author: Thomas Seifert / Mysnip-Solutions
  27. -url: http://www.mysnip-solutions.de/phorummodules/
  28. -
  29. -hook: lang|
  30. +title: Stop Forum Spam
  31. +desc: This module uses stopforumspam.com to check newly registered users against their database of known spammers
  32. +version: 0.1
  33. +author: Thomas Seifert / Mysnip-Solutions
  34. +url: http://www.mysnip-solutions.de/phorummodules/
  35. +
  36. +hook: lang|
  37.  hook: before_register|phorum_mod_stopforumspam_before_register
  38. \ No newline at end of file
  39. Common subdirectories: stopforumspam/lang and /tmp/stopforumspam/lang
  40. diff -u stopforumspam/settings.php /tmp/stopforumspam/settings.php
  41. --- stopforumspam/settings.php  2011-12-19 20:18:19.000000000 -0800
  42. +++ /tmp/stopforumspam/settings.php     2011-11-28 09:35:41.000000000 -0800
  43. @@ -17,14 +17,10 @@
  44.              'check_ip' => (!empty($_POST['check_ip']))?1:0,
  45.              'check_username' => (!empty($_POST['check_username']))?1:0,
  46.              'check_email' => (!empty($_POST['check_email']))?1:0,
  47. -            'force_generic' => (!empty($_POST['force_generic']))?1:0,
  48. -            'freq_min' => (!empty($_POST['freq_min'])) ? (int)($_POST['freq_min']) : 1,
  49.  
  50.              'apikey' => $_POST['apikey'],
  51.  
  52.          );
  53. -        if($PHORUM["mod_stopforumspam"]["freq_min"] < 1)
  54. -            $PHORUM["mod_stopforumspam"]["freq_min"] = 1;
  55.  
  56.          phorum_db_update_settings(array(
  57.              "mod_stopforumspam" => $PHORUM["mod_stopforumspam"]
  58. @@ -49,29 +45,9 @@
  59.  $frm->hidden("mod", "stopforumspam");
  60.  
  61.  // ----------------------------------------------------------------------
  62. -// Configure general settings
  63. -// ----------------------------------------------------------------------
  64. -
  65. -$frm->addrow(
  66. -    'API Key<small> (Get it from <a href="http://www.stopforumspam.com/signup">http://www.stopforumspam.com/signup</a>)</small>',
  67. -    $frm->text_box('apikey',$PHORUM["mod_stopforumspam"]['apikey'])
  68. -);
  69. -$row = $frm->addrow("Minimum Frequency Score:", $frm->text_box("freq_min", $PHORUM["mod_stopforumspam"]["freq_min"]));
  70. -$frm->addhelp(
  71. -    $row, "Spam score threshold",
  72. -    "If the total number of times the checked fields appear in the
  73. -     stopforumspam database exceeds this number, the registration
  74. -     will be considered spammy.  Adjust according to your checks
  75. -     and watch the event log for fale positives.<br/>
  76. -     <br/>
  77. -     Set to 1 for maximum protection."
  78. -);
  79. -
  80. -
  81. -// ----------------------------------------------------------------------
  82.  // Configure log settings
  83.  // ----------------------------------------------------------------------
  84. -
  85. +$frm->addrow('API Key<small> (Get it from <a href="http://www.stopforumspam.com/signup">http://www.stopforumspam.com/signup</a>)</small>',$frm->text_box('apikey',$PHORUM["mod_stopforumspam"]['apikey']));
  86.  $frm->addbreak("Log settings");
  87.  
  88.  if (!file_exists('./mods/event_logging')) {
  89. @@ -142,12 +118,7 @@
  90.       <br/>
  91.       A message is suspicious if it one of the selected checks fails."
  92.  );
  93. -$row = $frm->addrow('Return Generic Error',$frm->checkbox('force_generic',1,'Yes',$PHORUM['mod_stopforumspam']['force_generic']));
  94. -$frm->addhelp(
  95. -    $row, "Message type shown to blocked user",
  96. -    "Enabling this option will return a generic error message to the suspected spammer
  97. -     that does not contain any hints as to the source or reason for the block."
  98. -);
  99. +
  100.  
  101.  // ----------------------------------------------------------------------
  102.  // Configure spam hurdles for user registration
  103. @@ -159,6 +130,3 @@
  104.  $frm->addrow('Check Email address',$frm->checkbox('check_email',1,'Yes',$PHORUM['mod_stopforumspam']['check_email']));
  105.  
  106.  $frm->show();
  107. -
  108. -#print "<pre>"; print_r($PHORUM['mod_stopforumspam']); print "</pre>";
  109. -
  110. diff -u stopforumspam/stopforumspam.php /tmp/stopforumspam/stopforumspam.php
  111. --- stopforumspam/stopforumspam.php     2011-12-19 18:30:32.000000000 -0800
  112. +++ /tmp/stopforumspam/stopforumspam.php        2011-11-28 09:35:41.000000000 -0800
  113. @@ -13,8 +13,8 @@
  114.          if(!empty($PHORUM['mod_stopforumspam']['check_username'])) {
  115.              $args[]="username=".$userdata['username'];
  116.          }
  117. -        if(!empty($PHORUM['mod_stopforumspam']['check_email'])) {
  118. -            $args[]="email=".$userdata['email'];
  119. +        if(!empty($PHORUM['mod_stopforumspam']['check_username'])) {
  120. +            $args[]="username=".$userdata['username'];
  121.          }
  122.          if(count($args)) {
  123.              include_once("./include/api/http_get.php");
  124. @@ -22,11 +22,9 @@
  125.              // request serialized data
  126.              $args[]="f=serial";
  127.              $url = $baseurl.implode("&",$args);
  128. -            #_phorum_mod_stopforumspam_log("SFS query is $url", "", EVENTLOG_LVL_DEBUG);
  129.              $res = phorum_api_http_get($url);
  130.              if($res !== null) {
  131.                  $resdata = unserialize($res);
  132. -                $score = 0;
  133.                  foreach($resdata as $key => $var) {
  134.                      if($key == 'success') {
  135.                          if(empty($var)) {
  136. @@ -34,41 +32,29 @@
  137.                              _phorum_mod_stopforumspam_log('Check againt sfs api failed','The check against the stopforumspam.com API failed. We got no success message.\nData was:\n'.print_r($resdata,true));
  138.                              break;
  139.                          }
  140. -                    } elseif(!empty($var['appears'])) {
  141. -                        $last_key = $key;
  142. -                    }
  143. -                    if(!empty($var['frequency'])) {
  144. -                        $score += $var['frequency'];
  145. -                    }
  146. -                }
  147. -                #_phorum_mod_stopforumspam_log("score $score >= {$PHORUM["mod_stopforumspam"]["freq_min"]} ?", "", EVENTLOG_LVL_DEBUG);
  148. -                if(empty($PHORUM["mod_stopforumspam"]["freq_min"]) || $PHORUM["mod_stopforumspam"]["freq_min"] < 1)
  149. -                    $PHORUM["mod_stopforumspam"]["freq_min"] = 1; # hard min
  150. -                if($score >= $PHORUM["mod_stopforumspam"]["freq_min"]) {
  151. -                    if($PHORUM['mod_stopforumspam']['block_action'] == 'blockerror') {
  152. -                        // block user
  153. -                        if($PHORUM['mod_stopforumspam']['force_generic'] || !$last_key)
  154. -                            $error[]=$PHORUM['DATA']['LANG']['mod_stopforumspam']['error_generic'];
  155. -                        else
  156. -                            $error[]=$PHORUM['DATA']['LANG']['mod_stopforumspam']['error_'.$last_key];
  157.                      } else {
  158. -                        if($userdata["active"] == PHORUM_USER_ACTIVE) {
  159. -                            $userdata['active'] = PHORUM_USER_PENDING_MOD;
  160. -                        } elseif($userdata["active"] == PHORUM_USER_PENDING_EMAIL) {
  161. -                            $userdata['active'] = PHORUM_USER_PENDING_BOTH;
  162. +                        if(!empty($var['appears']) && $PHORUM['mod_stopforumspam']['block_action'] == 'blockerror') {
  163. +                            // block user
  164. +                            $error[]=$PHORUM['DATA']['LANG']['mod_stopforumspam']['error_'.$key];
  165. +                        } elseif(!empty($var['appears'])) {
  166. +                            if($userdata["active"] == PHORUM_USER_ACTIVE) {
  167. +                                $userdata['active'] = PHORUM_USER_PENDING_MOD;
  168. +                            } elseif($userdata["active"] == PHORUM_USER_PENDING_EMAIL) {
  169. +                                $userdata['active'] = PHORUM_USER_PENDING_BOTH;
  170. +                            }
  171.                          }
  172.                      }
  173.                  }
  174.                  if(count($error)) {
  175.                      if($PHORUM['mod_stopforumspam']['block_action'] == 'blockerror') {
  176. -                        _phorum_mod_stopforumspam_log("User {$userdata['username']} registration blocked! (score $score)","A user registration based on data from stopforumspam.com was blocked!\nUserdata was:\nUsername: {$userdata['username']}\nIP: {$_SERVER['REMOTE_ADDR']}\nEmail: {$userdata['email']}\n\nAnd data returned from Stopforumspam was:\n".print_r($resdata,true));
  177. +                        _phorum_mod_stopforumspam_log('User registration blocked!',"A user registration based on data from stopforumspam.com was blocked!\nUserdata was:\nUsername: {$userdata['username']}\nIP: {$_SERVER['REMOTE_ADDR']}\nEmail: {$userdata['email']}\n\nAnd data returned from Stopforumspam was:\n".print_r($resdata,true));
  178.                      } else {
  179. -                        _phorum_mod_stopforumspam_log("User registration made unapproved! (score $score)","A user registration based on data from stopforumspam.com was made unapproved!\nUserdata was:\nUsername: {$userdata['username']}\nIP: {$_SERVER['REMOTE_ADDR']}\nEmail: {$userdata['email']}\n\nAnd data returned from Stopforumspam was:\n".print_r($resdata,true));
  180. +                        _phorum_mod_stopforumspam_log('User registration made unapproved!',"A user registration based on data from stopforumspam.com was made unapproved!\nUserdata was:\nUsername: {$userdata['username']}\nIP: {$_SERVER['REMOTE_ADDR']}\nEmail: {$userdata['email']}\n\nAnd data returned from Stopforumspam was:\n".print_r($resdata,true));
  181.                      }
  182.                      $userdata['error']=implode("<br />",$error);
  183.                      $error = array();
  184.                  } else {
  185. -                    _phorum_mod_stopforumspam_log("User registration was safe (score $score)","A user registration was safe based on data from stopforumspam.com.\nUserdata was:\nUsername: {$userdata['username']}\nIP: {$_SERVER['REMOTE_ADDR']}\nEmail: {$userdata['email']}\n\nAnd data returned from Stopforumspam was:\n".print_r($resdata,true));
  186. +                    _phorum_mod_stopforumspam_log('User registration was safe',"A user registration was safe based on data from stopforumspam.com.\nUserdata was:\nUsername: {$userdata['username']}\nIP: {$_SERVER['REMOTE_ADDR']}\nEmail: {$userdata['email']}\n\nAnd data returned from Stopforumspam was:\n".print_r($resdata,true));
  187.  
  188.                  }
  189.              } else {
  190. @@ -79,14 +65,14 @@
  191.      }
  192.      return $userdata;
  193.  }
  194. -function _phorum_mod_stopforumspam_log($shortmsg,$message,$level=EVENTLOG_LVL_INFO) {
  195. +function _phorum_mod_stopforumspam_log($shortmsg,$message) {
  196.      global $PHORUM;
  197.      if (!empty($PHORUM["mod_stopforumspam"]["log_events"]) &&
  198.          function_exists('event_logging_writelog')) {
  199.          event_logging_writelog(array(
  200.              'message'   => $shortmsg,
  201.              'details'   => $message,
  202. -            'loglevel'  => $level
  203. +            'loglevel'  => EVENTLOG_LVL_INFO
  204.          ));
  205.      }
  206.  }
  207. \ No newline at end of file
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top