jdarwood007 commited on 2023-03-13 17:08:38
Showing 5 changed files, with 58 additions and 12 deletions.
Fixes #9
... | ... |
@@ -231,11 +231,16 @@ class SFSA |
231 | 231 |
array('check', 'sfs_enabled'), |
232 | 232 |
array('int', 'sfs_expire'), |
233 | 233 |
'', |
234 |
- array('check', 'sfs_emailcheck'), |
|
234 |
+ array('select', 'sfs_required', array( |
|
235 |
+ 'any' => $this->SFSclass->txt('sfs_required_any'), |
|
236 |
+ 'email|ip' => $this->SFSclass->txt('sfs_required_email_ip'), |
|
237 |
+ 'email|username' => $this->SFSclass->txt('sfs_required_email_username'), |
|
238 |
+ 'username|ip' => $this->SFSclass->txt('sfs_required_username_ip'), |
|
239 |
+ )), |
|
235 | 240 |
'', |
241 |
+ array('check', 'sfs_emailcheck'), |
|
236 | 242 |
array('check', 'sfs_usernamecheck'), |
237 | 243 |
array('float', 'sfs_username_confidence', 'step' => '0.01'), |
238 |
- '', |
|
239 | 244 |
array('check', 'sfs_ipcheck'), |
240 | 245 |
array('check', 'sfs_ipcheck_autoban'), |
241 | 246 |
'', |
... | ... |
@@ -761,16 +761,26 @@ class SFSL |
761 | 761 |
// This tells us what it matched on exactly. |
762 | 762 |
if (strpos($row['result'], ',') !== false) |
763 | 763 |
{ |
764 |
- list($resultType, $resultMatch, $extra) = explode(',', $row['result'] . ',,,'); |
|
765 |
- $result = sprintf($this->SFSclass->txt('sfs_log_matched_on'), $resultType, $resultMatch); |
|
764 |
+ $results = array(); |
|
765 |
+ $multiMatch = explode('|', $row['result'] . '|'); |
|
766 |
+ foreach ($multiMatch as $match) |
|
767 |
+ { |
|
768 |
+ if (empty($match)) |
|
769 |
+ continue; |
|
770 |
+ |
|
771 |
+ list($resultType, $resultMatch, $extra) = explode(',', $match . ',,,'); |
|
772 |
+ $res = sprintf($this->SFSclass->txt('sfs_log_matched_on'), $resultType, $resultMatch); |
|
766 | 773 |
|
767 | 774 |
// If this was a IP ban, note it. |
768 | 775 |
if ($resultType == 'ip' && !empty($extra)) |
769 |
- $result .= ' ' . $this->SFSclass->txt('sfs_log_auto_banned'); |
|
776 |
+ $res .= ' ' . $this->SFSclass->txt('sfs_log_auto_banned'); |
|
770 | 777 |
if ($resultType == 'username' && !empty($extra)) |
771 |
- $result .= ' ' . sprintf($this->SFSclass->txt('sfs_log_confidence'), $extra); |
|
778 |
+ $res .= ' ' . sprintf($this->SFSclass->txt('sfs_log_confidence'), $extra); |
|
779 |
+ |
|
780 |
+ $results[] = $res; |
|
781 |
+ } |
|
772 | 782 |
|
773 |
- return $result; |
|
783 |
+ return implode('<br>', $results); |
|
774 | 784 |
} |
775 | 785 |
|
776 | 786 |
return $row['result']; |
... | ... |
@@ -512,10 +512,31 @@ class SFS |
512 | 512 |
'email' => !empty($modSettings['sfs_emailcheck']) && !empty($response['email']) |
513 | 513 |
); |
514 | 514 |
|
515 |
- // Run all the checks, if we should. |
|
515 |
+ // Are we requiring multiple checks. |
|
516 |
+ if (!empty($modSettings['sfs_required']) && $modSettings['sfs_required'] != 'any') |
|
517 |
+ { |
|
518 |
+ // When requiring multiple checks, we require all to match. |
|
519 |
+ $requiredChecks = explode('|', $modSettings['sfs_required']); |
|
520 |
+ $result = true; |
|
521 |
+ $test = ''; |
|
522 |
+ foreach ($requiredChecks as $key) |
|
523 |
+ { |
|
524 |
+ $test = call_user_func(array($this, 'sfsCheck_' . $key), $response[$key], $area); |
|
525 |
+ $requestBlocked .= !empty($test) ? $test . '|' : ''; |
|
526 |
+ $result &= !empty($test); |
|
527 |
+ } |
|
528 |
+ |
|
529 |
+ // Not all checks passed, so we will allow it. |
|
530 |
+ if (!$result) |
|
531 |
+ $requestBlocked = ''; |
|
532 |
+ } |
|
533 |
+ // Otherwise we will check anything enabled and if any match, its found |
|
534 |
+ else |
|
535 |
+ { |
|
516 | 536 |
foreach ($checkMap as $key => $checkEnabled) |
517 | 537 |
if (empty($requestBlocked) && $checkEnabled) |
518 | 538 |
$requestBlocked = call_user_func(array($this, 'sfsCheck_' . $key), $response[$key], $area); |
539 |
+ } |
|
519 | 540 |
|
520 | 541 |
// Log all the stats? Debug mode here. |
521 | 542 |
$this->logAllStats('all', $checks, $requestBlocked); |
... | ... |
@@ -19,6 +19,13 @@ $txt['sfs_emailcheck'] = 'Check Email? (Recommended)'; |
19 | 19 |
$txt['sfs_enablesubmission'] = 'Enable Submissions'; |
20 | 20 |
$txt['sfs_apikey'] = '<a href="https://www.stopforumspam.com/keys">API Key</a>'; |
21 | 21 |
|
22 |
+/* Admin section: Required */ |
|
23 |
+$txt['sfs_required'] = 'Checks Required'; |
|
24 |
+$txt['sfs_required_any'] = 'Any [Email or Username | IP] (Default)'; |
|
25 |
+$txt['sfs_required_email_ip'] = 'Email & IP Address'; |
|
26 |
+$txt['sfs_required_email_username'] = 'Email & Username'; |
|
27 |
+$txt['sfs_required_username_ip'] = 'Username & IP Address'; |
|
28 |
+ |
|
22 | 29 |
/* Admin section: Region Config */ |
23 | 30 |
$txt['sfs_region'] = 'Geographic Access Region'; |
24 | 31 |
$txt['sfs_region_global'] = 'Global (Recommended)'; |
... | ... |
@@ -6,10 +6,6 @@ |
6 | 6 |
<version>1.3</version> |
7 | 7 |
<type>modification</type> |
8 | 8 |
|
9 |
- <install for="1.1.*"> |
|
10 |
- <readme lang="english" parsebbc="true" type="inline">This mod is [b]not compatible[/b] with your version of SMF, it requires 2.0 or later.</readme> |
|
11 |
- </install> |
|
12 |
- |
|
13 | 9 |
<!-- 2.0 has no support for hooks --> |
14 | 10 |
<install for="2.0.*"> |
15 | 11 |
<readme type="file" parsebbc="true">README.bbc</readme> |
... | ... |
@@ -28,6 +24,7 @@ |
28 | 24 |
|
29 | 25 |
<!-- language files --> |
30 | 26 |
<require-file name="language/StopForumSpam.english.php" destination="$themes_dir/default/languages" /> |
27 |
+ <require-file name="language/StopForumSpam.finnish.php" destination="$themes_dir/default/languages" /> |
|
31 | 28 |
|
32 | 29 |
<redirect url="?action=admin;area=modsettings;sa=sfs" /> |
33 | 30 |
</install> |
... | ... |
@@ -41,6 +38,7 @@ |
41 | 38 |
|
42 | 39 |
<!-- language files, removed --> |
43 | 40 |
<remove-dir name="$themes_dir/default/languages/StopForumSpam.english.php" /> |
41 |
+ <remove-dir name="$themes_dir/default/languages/StopForumSpam.finnish.php" /> |
|
44 | 42 |
|
45 | 43 |
<!-- source files, removed --> |
46 | 44 |
<remove-file name="$sourcedir/SFS.php" /> |
... | ... |
@@ -58,7 +56,9 @@ |
58 | 56 |
<require-file name="SFS-Subs-Admin.php" destination="$sourcedir" /> |
59 | 57 |
<require-file name="SFS-Subs-Logs.php" destination="$sourcedir" /> |
60 | 58 |
<require-file name="StopForumSpam.template.php" destination="$themedir" /> |
59 |
+ |
|
61 | 60 |
<require-file name="language/StopForumSpam.english.php" destination="$themes_dir/default/languages" /> |
61 |
+ <require-file name="language/StopForumSpam.finnish.php" destination="$themes_dir/default/languages" /> |
|
62 | 62 |
|
63 | 63 |
<!-- this dir may not exist in SMF --> |
64 | 64 |
<create-dir name="admin" destination="$themedir/images" /> |
... | ... |
@@ -105,6 +105,7 @@ |
105 | 105 |
|
106 | 106 |
<!-- language files, removed --> |
107 | 107 |
<remove-file name="$themes_dir/default/languages/StopForumSpam.english.php" /> |
108 |
+ <remove-file name="$themes_dir/default/languages/StopForumSpam.finnish.php" /> |
|
108 | 109 |
|
109 | 110 |
<!-- source files, removed --> |
110 | 111 |
<remove-file name="$sourcedir/SFS.php" /> |
... | ... |
@@ -116,9 +117,11 @@ |
116 | 117 |
|
117 | 118 |
<upgrade from="1.*" for="2.1.*"> |
118 | 119 |
<require-file name="language/StopForumSpam.english.php" destination="$themes_dir/default/languages" /> |
120 |
+ <require-file name="language/StopForumSpam.finnish.php" destination="$themes_dir/default/languages" /> |
|
119 | 121 |
<require-file name="StopForumSpam.template.php" destination="$themedir" /> |
120 | 122 |
<require-file name="SFS.php" destination="$sourcedir" /> |
121 | 123 |
<require-file name="SFS-Subs-Admin.php" destination="$sourcedir" /> |
124 |
+ <require-file name="SFS-Subs-Logs.php" destination="$sourcedir" /> |
|
122 | 125 |
<hook hook="integrate_pre_profile_areas" function="SFS::hook_pre_profile_areas" /> |
123 | 126 |
|
124 | 127 |
<!-- this dir may not exist in SMF --> |
125 | 128 |