Improve the documentation
jdarwood007

jdarwood007 commited on 2019-12-08 10:44:32
Showing 4 changed files, with 463 additions and 146 deletions.

... ...
@@ -1,44 +1,77 @@
1 1
 <?php
2 2
 
3
+/**
4
+ * The Main class for Stop Forum Spam
5
+ * @package StopForumSpam
6
+ * @author SleePy <sleepy @ simplemachines (dot) org>
7
+ * @copyright 2019
8
+ * @license 3-Clause BSD https://opensource.org/licenses/BSD-3-Clause
9
+ * @version 1.0.1
10
+ */
3 11
 class SFS
4 12
 {
5
-	/* Some URLs */
13
+	/**
14
+	 * @var string URLS we need to SFS for UI presentation.
15
+	 */
6 16
 	private $urlSFSipCheck = 'https://www.stopforumspam.com/ipcheck/%1$s';
7 17
 	private $urlSFSsearch = 'https://www.stopforumspam.com/search/%1$s';
8 18
 
9
-	/* Our Software/Version Info defaults */
19
+
20
+	/**
21
+	 * @var string Name of the software and its version.  This is so we can branch out from the same base.
22
+	 */
10 23
 	private $softwareName = 'smf';
11 24
 	private $softwareVersion = '2.1';
12 25
 
13
-	/* The admin page url */
26
+	/**
27
+	 * @var string The URL for the admin page.
28
+	 */
14 29
 	private $adminPageURL = null;
15 30
 
16
-	/* Settings we defaulted*/
31
+	/**
32
+	 * @var array Our settings information used on saving/changing settings.
33
+	 */
17 34
 	private $changedSettings = array();
18 35
 	private $extraVerificationOptions = array();
19 36
 
20
-	/* Search stuff */
37
+	/**
38
+	 * @var mixed Search area handling.
39
+	 */
21 40
 	private $search_params = array();
22 41
 	private $search_params_column = '';
23 42
 
24
-	/* Logs Disabled for */
43
+	/**
44
+	 * @var int How long we disable removing logs.
45
+	 */
25 46
 	private $hoursDisabled = 24;
26 47
 
27
-	/* Startup the class so we can call it later
28
-		@hook: SMF2.0: integrate_admin_areas
29
-		@hook: SMF2.1: integrate_admin_areas
30
-		@CalledIn: SMF 2.0, SMF 2.1
48
+	/**
49
+	 * Simple setup for the class to be used later correctly.
50
+	 * This simply loads the class into $smcFunc and we can grab this anywhere else later.
51
+	 *
52
+	 * @api
53
+	 * @CalledIn SMF 2.0, SMF 2.1
54
+	 * @version 1.0
55
+	 * @since 1.0
56
+	 * @uses integrate_pre_load - Hook SMF2.0
57
+	 * @uses integrate_pre_load - Hook SMF2.1 
58
+	 * @return void No return is generated
31 59
 	 */
32
-	public static function hook_pre_load()
60
+	public static function hook_pre_load(): void
33 61
 	{
34 62
 		global $smcFunc;
35 63
 		
36 64
 		$smcFunc['classSFS'] = new SFS();
37 65
 	}
38 66
 
39
-	/*
40
-		We do this once we construct
41
-		@CalledIn: SMF 2.0, SMF 2.1
67
+	/**
68
+	 * Build the class, figure out what software/version we have.
69
+	 * Loads up the defaults.
70
+	 *
71
+	 * @CalledIn SMF 2.0, SMF 2.1
72
+	 * @version 1.0
73
+	 * @since 1.0
74
+	 * @return void No return is generated
42 75
 	 */
43 76
 	public function __construct()
44 77
 	{
... ...
@@ -52,23 +85,41 @@ class SFS
52 85
 		$this->loadDefaults();
53 86
 	}
54 87
 
55
-	/*
56
-		Admin Panel areas addition
57
-		@CalledIn: SMF 2.0, SMF 2.1
58
-		@hook: SMF2.0: integrate__admin_areas
59
-		@hook: SMF2.1: integrate__admin_areas
88
+	/**
89
+	 * Creates the hook to the class for the admin areas.
90
+	 *
91
+	 * @param array $admin_areas A associate array from the software with all valid admin areas.
92
+	 *
93
+	 * @api
94
+	 * @CalledIn SMF 2.0, SMF 2.1
95
+	 * @see SFS::setupAdminAreas()
96
+	 * @version 1.0
97
+	 * @since 1.0
98
+	 * @uses integrate__admin_areas - Hook SMF2.0
99
+	 * @uses integrate__admin_areas - Hook SMF2.1 
100
+	 * @return void No return is generated
60 101
 	 */
61
-	public static function hook_admin_areas(&$admin_areas)
102
+	public static function hook_admin_areas(array &$admin_areas)
62 103
 	{
63 104
 		global $smcFunc;
64 105
 		return $smcFunc['classSFS']->setupAdminAreas($admin_areas);
65 106
 	}
66 107
 
67
-	/*
68
-		Does the actual setup of the admin areas
69
-		@CalledIn: SMF 2.0, SMF 2.1
108
+	/**
109
+	 * Startup the Admin Panels Additions.
110
+	 * Where things appear are based on what software/version you have.
111
+	 *
112
+	 * @param array $admin_areas A associate array from the software with all valid admin areas.
113
+	 *
114
+	 * @internal
115
+	 * @CalledIn SMF 2.0, SMF 2.1
116
+	 * @version 1.0
117
+	 * @since 1.0
118
+	 * @uses integrate__admin_areas - Hook SMF2.0
119
+	 * @uses integrate__admin_areas - Hook SMF2.1 
120
+	 * @return void No return is generated
70 121
 	 */
71
-	public function setupAdminAreas(&$admin_areas)
122
+	private function setupAdminAreas(array &$admin_areas): void
72 123
 	{
73 124
 		global $txt, $scripturl;
74 125
 
... ...
@@ -100,53 +151,86 @@ class SFS
100 151
 				$txt['sfs_admin_logs']
101 152
 			);
102 153
 		}
103
-
104
-		return;
105 154
 	}
106 155
 
107
-	/*
108
-		Only do this for 2.0, but we put it in the mod section.
109
-		@hook: SMF2.0: integrate_modify_modifications
110
-		@hook: SMF2.1: 
111
-		@CalledIn: SMF 2.0
156
+	/**
157
+	 * Setup the Modification's setup page.
158
+	 * For some versions, we put the logs into the modifications sections, its easier.
159
+	 *
160
+	 * @param array $subActions A associate array from the software with all valid modification sections.
161
+	 *
162
+	 * @api
163
+	 * @CalledIn SMF 2.0, SMF 2.1
164
+	 * @see SFS::setupModifyModifications()
165
+	 * @version 1.0
166
+	 * @since 1.0
167
+	 * @uses integrate_modify_modifications - Hook SMF2.0
168
+	 * @uses integrate_modify_modifications - Hook SMF2.1
169
+	 * @return void No return is generated
112 170
 	 */
113
-	public static function hook_modify_modifications(&$subActions)
171
+	public static function hook_modify_modifications(array &$subActions)
114 172
 	{
115 173
 		global $smcFunc;
116 174
 		return $smcFunc['classSFS']->setupModifyModifications($subActions);
117 175
 	}
118 176
 
119
-	/*
120
-		Setup the Configuration page.
121
-		@CalledIn: SMF 2.0
177
+	/**
178
+	 * Setup the Modifications section links.
179
+	 * For some versions we add the logs here as well.
180
+	 *
181
+	 * @param array $subActions A associate array from the software with all valid modification sections.
182
+	 *
183
+	 * @internal
184
+	 * @CalledIn SMF 2.0, SMF 2.1
185
+	 * @version 1.0
186
+	 * @since 1.0
187
+	 * @uses integrate_modify_modifications - Hook SMF2.0
188
+	 * @uses integrate_modify_modifications - Hook SMF2.1
189
+	 * @return void No return is generated
122 190
 	 */
123
-	public function setupModifyModifications(&$subActions)
191
+	private function setupModifyModifications(array &$subActions): void
124 192
 	{
125 193
 		$subActions['sfs'] = 'SFS::startupAdminConfiguration';
126 194
 
127 195
 		// Only in SMF 2.0 do we drop logs here.
128 196
 		if ($this->versionCheck('2.0', 'smf'))
129 197
 			$subActions['sfslog'] = 'SFS::startupLogs';
130
-
131
-		return;
132 198
 	}
133 199
 
134
-	/*
135
-		Only need to do this for SMF 2.0, SMF 2.1 calls hook_manage_logs
136
-		@hook: SMF2.0: integrate_modify_modifications
137
-		@CalledIn: SMF 2.0
200
+	/**
201
+	 * The configuration caller.
202
+	 *
203
+	 * @param bool $return_config If true, returns the configuration options for searches.
204
+	 *
205
+	 * @api
206
+	 * @CalledIn SMF 2.0, SMF 2.1
207
+	 * @see SFS::setupSFSConfiguration
208
+	 * @version 1.0
209
+	 * @since 1.0
210
+	 * @uses integrate_modify_modifications - Hook SMF2.0
211
+	 * @uses integrate_modify_modifications - Hook SMF2.1
212
+	 * @return void No return is generated
138 213
 	 */
139
-	public static function startupAdminConfiguration($return_config = false)
214
+	public static function startupAdminConfiguration(bool $return_config = false)
140 215
 	{
141 216
 		global $smcFunc;
142 217
 		return $smcFunc['classSFS']->setupSFSConfiguration($return_config);
143 218
 	}
144 219
 
145
-	/*
146
-		The settings page.
147
-		@CalledIn: SMF 2.0, SMF 2.1
220
+	/**
221
+	 * The actual settings page.
222
+	 *
223
+	 * @param bool $return_config If true, returns the configuration options for searches.
224
+	 *
225
+	 * @internal
226
+	 * @CalledIn SMF 2.0, SMF 2.1
227
+	 * @version 1.0
228
+	 * @since 1.0
229
+	 * @uses integrate_modify_modifications - Hook SMF2.0
230
+	 * @uses integrate_modify_modifications - Hook SMF2.1
231
+	 * @return void No return is generated
148 232
 	 */
149
-	public function setupSFSConfiguration($return_config = false)
233
+	private function setupSFSConfiguration(bool $return_config = false): array
150 234
 	{
151 235
 		global $txt, $scripturl, $context, $settings, $sc, $modSettings;
152 236
 
... ...
@@ -211,46 +295,75 @@ class SFS
211 295
 
212 296
 		prepareDBSettingContext($config_vars);
213 297
 
214
-		return;
298
+		return array();
215 299
 	}
216 300
 
217
-	/*
218
-		In SMF 2.1 we do this hook.
219
-		@hook: SMF2.0:
220
-		@hook: SMF2.1: integrate_manage_logs
221
-		@CalledIn: SMF 2.1
301
+	/**
302
+	 * In some software/versions, we can hook into the logs section.
303
+	 * In others we hook into the modifications settings.
304
+	 *
305
+	 * @param bool $return_config If true, returns empty array to prevent breaking old SMF installs.
306
+	 *
307
+	 * @api
308
+	 * @CalledIn SMF 2.1
309
+	 * @See SFS::startupLogs
310
+	 * @version 1.0
311
+	 * @since 1.0
312
+	 * @uses integrate_manage_logs - Hook SMF2.1
313
+	 * @return void No return is generated
222 314
 	 */
223
-	public static function hook_manage_logs(&$log_functions)
315
+	public static function hook_manage_logs(array &$log_functions):void 
224 316
 	{
225 317
 		global $smcFunc;
226 318
 
319
+		// Add our logs sub action.
227 320
 		$log_functions['sfslog'] = array('StopForumSpam.php', 'startupLogs');
228 321
 
322
+		// Add it to the menu as well.
229 323
 		$context[$context['admin_menu_name']]['tab_data']['tabs']['sfslog'] = array(
230 324
 			'description' => $txt['sfs_admin_logs'],
231 325
 		);
232
-
233
-		return;
234 326
 	}
235 327
 
236
-	/*
237
-		Show the logs as called by SMF from either hook_manage_logs (SMF 2.1) or setupModifyModifications (SMF 2.0)
328
+	/**
329
+	 * Log startup caller.
330
+	 * This has a $return_config just for simply complying with properly for searching the admin panel.
331
+	 *
332
+	 * @param bool $return_config If true, returns empty array to prevent breaking old SMF installs.
333
+	 *
334
+	 * @api
335
+	 * @CalledIn SMF 2.1
336
+	 * @See SFS::loadLogs
337
+	 * @version 1.0
338
+	 * @since 1.0
339
+	 * @uses hook_manage_logs - Hook SMF2.1
340
+	 * @uses setupModifyModifications - Injected SMF2.0
341
+	 * @return void No return is generated
238 342
 	 */
239
-	public static function startupLogs($return_config = false)
343
+	public static function startupLogs(bool $return_config = false): array
240 344
 	{
241 345
 		global $smcFunc;
242 346
 
243
-		// No Configs.
244
-		if ($return_config)
245
-			return array();
246
-
247 347
 		return $smcFunc['classSFS']->loadLogs();
248 348
 	}
249 349
 
250
-	/*
251
-		Actually load up logs
350
+	/**
351
+	 * Actually show the logs.
352
+	 * This has a $return_config just for simply complying with properly for searching the admin panel.
353
+	 *
354
+	 * @param bool $return_config If true, returns empty array to prevent breaking old SMF installs.
355
+	 *
356
+	 * @api
357
+	 * @CalledIn SMF2.0, SMF 2.1
358
+	 * @See SFS::getSFSLogEntries
359
+	 * @See SFS::getSFSLogEntriesCount
360
+	 * @version 1.0
361
+	 * @since 1.0
362
+	 * @uses hook_manage_logs - Hook SMF2.1
363
+	 * @uses setupModifyModifications - Injected SMF2.0
364
+	 * @return void No return is generated
252 365
 	 */
253
-	public function loadLogs($return_config = false)
366
+	public function loadLogs(bool $return_config = false): array
254 367
 	{
255 368
 		global $context, $txt, $smcFunc, $sourcedir;
256 369
 
... ...
@@ -346,7 +459,7 @@ class SFS
346 459
 					'data' => array(
347 460
 						'db' => 'url',
348 461
 						'class' => 'smalltext',
349
-						'style' => 'word-wrap: break-word;',
462
+						'style' => 'word-break: break-all;',
350 463
 					),
351 464
 					'sort' => array(
352 465
 						'default' => 'l.url DESC',
... ...
@@ -484,15 +597,33 @@ class SFS
484 597
 
485 598
 		$context['sub_template'] = 'show_list';
486 599
 		$context['default_list'] = 'sfslog_list';
600
+
601
+		return array();
487 602
 	}
488 603
 
489
-	/*
490
-		Get the Log entries
604
+	/**
605
+	 * Get the log data and returns it ready to go for GenericList handling.
606
+	 *
607
+	 * @param int $start The index for where we offset or start at for the list
608
+	 * @param int $items_per_page How many items we are going to show on this page.
609
+	 * @param string $sort The column we are sorting by.
610
+	 * @param string $query_string The search string we are using to filter log data.
611
+	 * @param array $query_params Extra parameters for searching.
612
+	 *
613
+	 * @api
614
+	 * @CalledIn SMF 2.0, SMF 2.1
615
+	 * @See SFS::loadLogs
616
+	 * @version 1.0
617
+	 * @since 1.0
618
+	 * @uses hook_manage_logs - Hook SMF2.1
619
+	 * @uses setupModifyModifications - Injected SMF2.0
620
+	 * @return void No return is generated
491 621
 	 */
492
-	public function getSFSLogEntries($start, $items_per_page, $sort, $query_string = '', $query_params = array())
622
+	public function getSFSLogEntries(int $start, int $items_per_page, string $sort, string $query_string = '', array $query_params = array()): array
493 623
 	{
494 624
 		global $context, $smcFunc, $txt;
495 625
 
626
+		// Fetch all of our logs.
496 627
 		$result = $smcFunc['db_query']('', '
497 628
 			SELECT
498 629
 				l.id_sfs,
... ...
@@ -541,13 +672,14 @@ class SFS
541 672
 
542 673
 			$checksDecoded = $this->decodeJSON($row['checks']);
543 674
 
544
-			// Checks, username
675
+			// If we know what check triggered this, link it up to be searched.
545 676
 			if ($row['id_type'] == 1)
546 677
 				$entries[$row['id_sfs']]['checks'] = '<a href="' . sprintf($this->urlSFSsearch, $checksDecoded['value']) . '">' . $checksDecoded['value'] . '</a>';
547 678
 			elseif ($row['id_type'] == 2)
548 679
 				$entries[$row['id_sfs']]['checks'] = '<a href="' . sprintf($this->urlSFSsearch, $checksDecoded['value']) . '">' . $checksDecoded['value'] . '</a>';
549 680
 			elseif ($row['id_type'] == 3)
550 681
 				$entries[$row['id_sfs']]['checks'] = '<a href="' . sprintf($this->urlSFSsearch, $checksDecoded['value']) . '">' . $checksDecoded['value'] . '</a>';
682
+			// No idea what triggered it, parse it out cleanly.  Could be debug data as well.
551 683
 			else
552 684
 			{
553 685
 				$entries[$row['id_sfs']]['checks'] = '';
... ...
@@ -557,7 +689,7 @@ class SFS
557 689
 						$entries[$row['id_sfs']]['checks'] .= ucfirst($key) . ':' . $value . '<br>';					
558 690
 			}
559 691
 
560
-			// $results
692
+			// This tells us what it matched on exactly.
561 693
 			if (strpos($row['result'], ',') !== false)
562 694
 			{
563 695
 				list($resultType, $resultMatch) = explode(',', $row['result']);
... ...
@@ -572,10 +704,22 @@ class SFS
572 704
 		return $entries;
573 705
 	}
574 706
 
575
-	/*
576
-		Get the Counter Log entries
707
+	/**
708
+	 * Get the log counts and returns it ready to go for GenericList handling.
709
+	 *
710
+	 * @param string $query_string The search string we are using to filter log data.
711
+	 * @param array $query_params Extra parameters for searching.
712
+	 *
713
+	 * @api
714
+	 * @CalledIn SMF 2.0, SMF 2.1
715
+	 * @See SFS::loadLogs
716
+	 * @version 1.0
717
+	 * @since 1.0
718
+	 * @uses hook_manage_logs - Hook SMF2.1
719
+	 * @uses setupModifyModifications - Injected SMF2.0
720
+	 * @return void No return is generated
577 721
 	 */
578
-	public function getSFSLogEntriesCount($query_string = '', $query_params = array(), $log_type = 1)
722
+	public function getSFSLogEntriesCount(string $query_string = '', array $query_params = array()): int
579 723
 	{
580 724
 		global $smcFunc, $user_info;
581 725
 
... ...
@@ -594,13 +738,20 @@ class SFS
594 738
 		list ($entry_count) = $smcFunc['db_fetch_row']($result);
595 739
 		$smcFunc['db_free_result']($result);
596 740
 
597
-		return $entry_count;
741
+		return (int) $entry_count;
598 742
 	}
599 743
 
600
-	/*
601
-		Remove all logs, except for those 24 horus or newer.
744
+	/**
745
+	 * Remove all logs, except those less than 24 hours old.
746
+	 *
747
+	 * @api
748
+	 * @CalledIn SMF 2.0, SMF 2.1
749
+	 * @See SFS::loadLogs
750
+	 * @version 1.0
751
+	 * @since 1.0
752
+	 * @return void No return is generated
602 753
 	 */
603
-	private function removeAllLogs()
754
+	private function removeAllLogs(): void
604 755
 	{
605 756
 		global $smcFunc;
606 757
 
... ...
@@ -615,10 +766,19 @@ class SFS
615 766
 		);
616 767
 	}
617 768
 
618
-	/*
619
-		Remove specific logs, except for those 24 horus or newer.
769
+	/**
770
+	 * Remove specific logs, except those less than 24 hours old.
771
+	 *
772
+	 * @param array $entries A array of the ids that we want to remove.
773
+	 *
774
+	 * @api
775
+	 * @CalledIn SMF 2.0, SMF 2.1
776
+	 * @See SFS::loadLogs
777
+	 * @version 1.0
778
+	 * @since 1.0
779
+	 * @return void No return is generated
620 780
 	 */
621
-	private function removeLogs($entries)
781
+	private function removeLogs(array $entries): void
622 782
 	{
623 783
 		global $smcFunc;
624 784
 
... ...
@@ -635,23 +795,45 @@ class SFS
635 795
 		);
636 796
 	}
637 797
 
638
-	/*
639
-		Handle registration events
640
-		@CalledIn: SMF 2.0, SMF 2.1
641
-		@calledAt: action=signup, action=admin;area=regcenter;sa=register
642
-		@hook: SMF2.0: integrate_register
643
-		@hook: SMF2.1: integrate_register
798
+	/**
799
+	 * Handle registration events.
800
+	 *
801
+	 * @param array $regOptions An array from the software with all the registration optins we are going to use to register.
802
+	 * @param array $theme_vars An array from the software with all the possible theme settings we are going to use to register.
803
+	 *
804
+	 * @api
805
+	 * @CalledIn SMF 2.0, SMF 2.1
806
+	 * @CalledAt: action=signup, action=admin;area=regcenter;sa=register
807
+	 * @See SFS::checkRegisterRequest
808
+	 * @version 1.0
809
+	 * @since 1.0
810
+	 * @uses integrate_register - Hook SMF2.1
811
+	 * @uses integrate_register - Hook SMF2.0
812
+	 * @return bool True is success, no other bool is expeicifcly defined yet.
644 813
 	 */
645
-	public static function hook_register(&$regOptions, &$theme_vars)
814
+	public static function hook_register(array &$regOptions, array &$theme_vars): bool
646 815
 	{
647 816
 		global $smcFunc;
648 817
 		return $smcFunc['classSFS']->checkRegisterRequest($regOptions, $theme_vars);
649 818
 	}
650 819
 
651
-	/*
652
-		Something is attempting to register, we should check them out.
820
+	/**
821
+	 * Something is attempting to register, we should check them out.
822
+	 *
823
+	 * @param array $regOptions An array from the software with all the registration optins we are going to use to register.
824
+	 * @param array $theme_vars An array from the software with all the possible theme settings we are going to use to register.
825
+	 *
826
+	 * @api
827
+	 * @CalledIn SMF 2.0, SMF 2.1
828
+	 * @CalledAt: action=signup, action=admin;area=regcenter;sa=register
829
+	 * @See SFS::checkRegisterRequest
830
+	 * @version 1.0
831
+	 * @since 1.0
832
+	 * @uses integrate_register - Hook SMF2.1
833
+	 * @uses integrate_register - Hook SMF2.0
834
+	 * @return bool True is success, no other bool is expeicifcly defined yet.
653 835
 	 */
654
-	public function checkRegisterRequest(&$regOptions, &$theme_vars)
836
+	private function checkRegisterRequest(array &$regOptions, array &$theme_vars): bool
655 837
 	{
656 838
 		// Admins are not spammers.. usually.
657 839
 		if ($regOptions['interface'] == 'admin')
... ...
@@ -660,7 +843,7 @@ class SFS
660 843
 		$this->loadLanguage();
661 844
 
662 845
 		// Pass everything and let us handle what options we pass on.  We pass the register_vars as these are what we have cleaned up.
663
-		$this->sfsCheck(array(
846
+		return $this->sfsCheck(array(
664 847
 			array('username' => $regOptions['register_vars']['member_name']),
665 848
 			array('email' => $regOptions['register_vars']['email_address']),
666 849
 			array('ip' => $regOptions['register_vars']['member_ip']),
... ...
@@ -668,22 +851,42 @@ class SFS
668 851
 		), 'register');
669 852
 	}
670 853
 
671
-	/*
672
-		Handle verification events, except register.
673
-		@CalledIn: SMF 2.1
674
-		@hook: SMF2.1: integrate_create_control_verification_test
854
+	/**
855
+	 * The caller for a verification test.
856
+	 *
857
+	 * @param array $thisVerification An array from the software with all the verification information we have.
858
+	 * @param array $verification_errors An errors which exist from verification.
859
+	 *
860
+	 * @api
861
+	 * @CalledIn SMF 2.0, SMF 2.1
862
+	 * @See SFS::checkVerificationTest
863
+	 * @version 1.0
864
+	 * @since 1.0
865
+	 * @uses integrate_create_control_verification_test - Hook SMF2.1
866
+	 * @return bool True is success, no other bool is expeicifcly defined yet.
675 867
 	 */
676
-	public static function hook_create_control_verification_test($thisVerification, &$verification_errors)
868
+	public static function hook_create_control_verification_test(array $thisVerification, array &$verification_errors): bool
677 869
 	{
678 870
 		global $smcFunc;
679
-		$smcFunc['classSFS']->checkVerificationTest($thisVerification, $verification_errors);
680
-	}
681
-	
682
-	/*
683
-		Something is attempting to post, we should check them out.
684
-		SMF 2.0 calls this directly as it doesnn't have a hook.
871
+		return $smcFunc['classSFS']->checkVerificationTest($thisVerification, $verification_errors);
872
+	}
873
+
874
+	/**
875
+	 * The caller for a verification test.
876
+	 * SMF 2.0 calls this directly as we have no good hook.
877
+	 *
878
+	 * @param array $thisVerification An array from the software with all the verification information we have.
879
+	 * @param array $verification_errors An errors which exist from verification.
880
+	 *
881
+	 * @api
882
+	 * @CalledIn SMF 2.0, SMF 2.1
883
+	 * @version 1.0
884
+	 * @since 1.0
885
+	 * @uses create_control_verification - Hook SMF2.0
886
+	 * @uses integrate_create_control_verification_test - Hook SMF2.1
887
+	 * @return bool True is success, no other bool is expeicifcly defined yet.
685 888
 	 */
686
-	public function checkVerificationTest($thisVerification, &$verification_errors)
889
+	public function checkVerificationTest(array $thisVerification, array &$verification_errors): bool
687 890
 	{
688 891
 		global $user_info;
689 892
 
... ...
@@ -694,6 +897,7 @@ class SFS
694 897
 		// Get our language in here.
695 898
 		$this->loadLanguage();
696 899
 
900
+		// Get our options data.
697 901
 		$options = $this->getVerificationOptions();
698 902
 
699 903
 		// Posting?
... ...
@@ -777,13 +981,23 @@ class SFS
777 981
 
778 982
 			return $this->sfsCheck($checks, $option);
779 983
 		}
780
-die;
984
+
985
+		return true;
781 986
 	}
782 987
 
783
-	/*
784
-		Check data against the SFS database
988
+	/**
989
+	 * Run checks against the SFS database.
990
+	 *
991
+	 * @param array $checks All the possible checks we would like to preform.
992
+	 * @param string $area The area this is coming from.
993
+	 *
994
+	 * @internal
995
+	 * @CalledIn SMF 2.0, SMF 2.1
996
+	 * @version 1.0
997
+	 * @since 1.0
998
+	 * @return bool True is success, no other bool is expeicifcly defined yet.
785 999
 	 */
786
-	public function sfsCheck($checks, $area = null)
1000
+	private function sfsCheck(array $checks, string $area = null): bool
787 1001
 	{
788 1002
 		global $sourcedir, $smcFunc, $context, $modSettings, $txt;
789 1003
 
... ...
@@ -902,13 +1116,23 @@ die;
902 1116
 		fatal_error($txt['sfs_request_blocked']);
903 1117
 	}
904 1118
 
905
-	/*
906
-		Log the blocked request for later
1119
+	/**
1120
+	 * Log that this was blocked.
1121
+	 *
1122
+	 * @param string $type Either username, email, or ip.  Anything else gets marked uknown.
1123
+	 * @param array $check The check data we are logging.
1124
+	 *
1125
+	 * @internal
1126
+	 * @CalledIn SMF 2.0, SMF 2.1
1127
+	 * @version 1.0
1128
+	 * @since 1.0
1129
+	 * @return bool True is success, no other bool is expeicifcly defined yet.
907 1130
 	 */
908
-	private function logBlockedStats($type, $check)
1131
+	private function logBlockedStats(string $type, array $check): void
909 1132
 	{
910 1133
 		global $smcFunc, $user_info;
911 1134
 
1135
+		// What type of log is this?
912 1136
 		switch($type)
913 1137
 		{
914 1138
 			case 'username':
... ...
@@ -955,10 +1179,20 @@ die;
955 1179
 		);
956 1180
 	}
957 1181
 
958
-	/*
959
-		Log all the data for later.
1182
+	/**
1183
+	 * Debug logging that this was blocked..
1184
+	 *
1185
+	 * @param string $type Either error or all, currently ignored.
1186
+	 * @param array $check The check data we are logging.
1187
+	 * @param string $DebugMessage Debugging message, sometimes just is error or failure, otherwise a comma separated of what request was blocked.
1188
+	 *
1189
+	 * @internal
1190
+	 * @CalledIn SMF 2.0, SMF 2.1
1191
+	 * @version 1.0
1192
+	 * @since 1.0
1193
+	 * @return bool True is success, no other bool is expeicifcly defined yet.
960 1194
 	 */
961
-	private function logAllStats($type, $checks, $requestBlocked)
1195
+	private function logAllStats(string $type, array $checks, string $DebugMessage): void
962 1196
 	{
963 1197
 		global $smcFunc, $user_info;
964 1198
 
... ...
@@ -992,12 +1226,20 @@ die;
992 1226
 		);
993 1227
 	}
994 1228
 
995
-	/*
996
-		Decode JSON data.
997
-		If we have $smcFunc['json_decode'] we use it as it can handle errors.
998
-		Otherwise we do some basic stuff.
1229
+	/**
1230
+	 * Decode JSON data and return it.
1231
+	 * If we have $smcFunc['json_decode'], we use this as it handles errors natively.
1232
+	 * For all others, we simply ensure a proper array is returned in the event of a error. 
1233
+	 *
1234
+	 * @param string $requestData A properly formatted json string.
1235
+	 *
1236
+	 * @internal
1237
+	 * @CalledIn SMF 2.0, SMF 2.1
1238
+	 * @version 1.0
1239
+	 * @since 1.0
1240
+	 * @return array The parsed json string is now an array.
999 1241
 	 */
1000
-	private function decodeJSON($requestData)
1242
+	private function decodeJSON(string $requestData): array
1001 1243
 	{
1002 1244
 		global $smcFunc;
1003 1245
 
... ...
@@ -1017,11 +1259,17 @@ die;
1017 1259
 		}
1018 1260
 	}
1019 1261
 
1020
-	/*
1021
-		Build the base URL for the Stop Forum Spam website
1022
-		@resource: https://www.stopforumspam.com/usage
1262
+	/**
1263
+	 * Build the SFS Server URL based on our configuration setup. 
1264
+	 *
1265
+	 * @internal
1266
+	 * @link: https://www.stopforumspam.com/usage
1267
+	 * @CalledIn SMF 2.0, SMF 2.1
1268
+	 * @version 1.0
1269
+	 * @since 1.0
1270
+	 * @return array The parsed json string is now an array.
1023 1271
 	 */
1024
-	public function buildServerURL()
1272
+	private function buildServerURL(): string
1025 1273
 	{
1026 1274
 		global $modSettings;
1027 1275
 		static $url = null;
... ...
@@ -1067,11 +1315,17 @@ die;
1067 1315
 		return $url;
1068 1316
 	}
1069 1317
 
1070
-	/*
1071
-		Setup our possible SFS hosts.
1072
-		@resource: https://www.stopforumspam.com/usage
1318
+	/**
1319
+	 * Setup our possible SFS hosts. 
1320
+	 *
1321
+	 * @internal
1322
+	 * @link: https://www.stopforumspam.com/usage
1323
+	 * @CalledIn SMF 2.0, SMF 2.1
1324
+	 * @version 1.0
1325
+	 * @since 1.0
1326
+	 * @return array The list of servers.
1073 1327
 	 */
1074
-	public function sfsServerMapping($returnType = null)
1328
+	private function sfsServerMapping($returnType = null)
1075 1329
 	{
1076 1330
 		global $txt;
1077 1331
 
... ...
@@ -1106,8 +1360,14 @@ die;
1106 1360
 		return $serverList;
1107 1361
 	}
1108 1362
 
1109
-	/*
1110
-		Verification Options
1363
+	/**
1364
+	 * Our possible verification options.
1365
+	 *
1366
+	 * @internal
1367
+	 * @CalledIn SMF 2.0, SMF 2.1
1368
+	 * @version 1.0
1369
+	 * @since 1.0
1370
+	 * @return array The list of servers.
1111 1371
 	 */
1112 1372
 	private function getVerificationOptions()
1113 1373
 	{
... ...
@@ -1134,9 +1394,17 @@ die;
1134 1394
 		return $options;
1135 1395
 	}
1136 1396
 
1137
-	/*
1138
-		Defaults for SFS
1139
-		We don't specify all of them here, just what we need to make development easier.
1397
+	/**
1398
+	 * Our possible default options.
1399
+	 * We don't specify them all, just ones that make sense for code development.
1400
+	 *
1401
+	 * @param bool $undo If true, we reverse any defaults we set.  Makes the admin page work.
1402
+	 *
1403
+	 * @internal
1404
+	 * @CalledIn SMF 2.0, SMF 2.1
1405
+	 * @version 1.0
1406
+	 * @since 1.0
1407
+	 * @return void Nothing is returned, we inject into $modSettings.
1140 1408
 	 */
1141 1409
 	public function loadDefaults($undo = false)
1142 1410
 	{
... ...
@@ -1173,19 +1441,33 @@ die;
1173 1441
 			}
1174 1442
 	}
1175 1443
 
1176
-	/*
1177
-		Just a wrapper to tell defaults to undo.
1444
+	/**
1445
+	 * We undo the defaults letting us save the admin page properly.
1446
+	 *
1447
+	 * @internal
1448
+	 * @CalledIn SMF 2.0, SMF 2.1
1449
+	 * @version 1.0
1450
+	 * @since 1.0
1451
+	 * @return void Nothing is returned, we inject into $modSettings.
1178 1452
 	 */
1179 1453
 	public function unloadDefaults()
1180 1454
 	{
1181 1455
 		return $this->loadDefaults(true);
1182 1456
 	}
1183 1457
 
1184
-	/*
1185
-		Global function to check version and software matches.
1186
-		@CalledIn: SMF 2.0, SMF 2.1
1458
+	/**
1459
+	 * Checks if we are matching an array of versions against a specific version.
1460
+	 *
1461
+	 * @param string|array $version The version to check, this is converted to an array later on.
1462
+	 * @param string $software The software we are matching against.
1463
+	 *
1464
+	 * @internal
1465
+	 * @CalledIn SMF 2.0, SMF 2.1
1466
+	 * @version 1.0
1467
+	 * @since 1.0
1468
+	 * @return bool True if we matched a version, false otherwise.
1187 1469
 	 */
1188
-	public function versionCheck($version, $software = 'smf')
1470
+	public function versionCheck($version, string $software = 'smf'): bool
1189 1471
 	{
1190 1472
 		// We can't do this if the software doesn't match.
1191 1473
 		if ($software !== $this->softwareName)
... ...
@@ -1201,29 +1483,43 @@ die;
1201 1483
 		return false;
1202 1484
 	}
1203 1485
 
1204
-	/*
1205
-		Global loadLanguage function, should we want to split it out or need to load it differently
1206
-		@CalledIn: SMF 2.0, SMF 2.1
1486
+	/**
1487
+	 * A global function for loading our lanague up.
1488
+	 * Placeholder to allow easier additional loading or other software/versions to change this as needed.
1489
+	 *
1490
+	 * @internal
1491
+	 * @CalledIn SMF 2.0, SMF 2.1
1492
+	 * @version 1.0
1493
+	 * @since 1.0
1494
+	 * @return void No return is generated here.
1207 1495
 	 */
1208
-	public function loadLanguage()
1496
+	public function loadLanguage(): void
1209 1497
 	{
1210 1498
 		// Load the langauge.
1211 1499
 		loadLanguage('StopForumSpam');
1212 1500
 	}
1213 1501
 
1214
-	/*
1215
-		Handle searching for logs
1502
+	/**
1503
+	 * Handle searching for logs.
1504
+	 *
1505
+	 * @internal
1506
+	 * @CalledIn SMF 2.0, SMF 2.1
1507
+	 * @version 1.0
1508
+	 * @since 1.0
1509
+	 * @return void No return is generated here.
1216 1510
 	 */
1217
-	private function handleLogSearch()
1511
+	private function handleLogSearch(): void
1218 1512
 	{
1219 1513
 		global $context, $txt;
1220 1514
 
1515
+		// If we have some data from a search, lets bring it back out.
1221 1516
 		if (!empty($_REQUEST['params']) && empty($_REQUEST['is_search']))
1222 1517
 		{
1223 1518
 			$this->search_params = base64_decode(strtr($_REQUEST['params'], array(' ' => '+')));
1224 1519
 			$this->search_params = $this->JSONDecode($this->search_params);
1225 1520
 		}
1226 1521
 
1522
+		// What we can search.
1227 1523
 		$searchTypes = array(
1228 1524
 			'url' => array('sql' => 'l.url', 'label' => $txt['sfs_log_search_url']),
1229 1525
 			'member' => array('sql' => 'mem.real_name', 'label' => $txt['sfs_log_search_member']),
... ...
@@ -1233,6 +1529,7 @@ die;
1233 1529
 			'ip2' => array('sql' => 'lm.ip2', 'label' => $txt['sfs_log_search_ip2'])
1234 1530
 		);
1235 1531
 
1532
+		// What we want to search for.
1236 1533
 		if (!isset($this->search_params['string']) || (!empty($_REQUEST['search']) && $this->search_params['string'] != $_REQUEST['search']))
1237 1534
 			$this->search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search'];
1238 1535
 		else
... ...
@@ -1,4 +1,11 @@
1 1
 <?php
2
+/**
3
+ * The Main class for Stop Forum Spam
4
+ * @package StopForumSpam
5
+ * @author SleePy <sleepy @ simplemachines (dot) org>
6
+ * @copyright 2019
7
+ * @license 3-Clause BSD https://opensource.org/licenses/BSD-3-Clause
8
+ */
2 9
 
3 10
 // If we have found SSI.php and we are outside of SMF, then we are running standalone.
4 11
 if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
... ...
@@ -1,4 +1,11 @@
1 1
 <?php
2
+/**
3
+ * The Main class for Stop Forum Spam
4
+ * @package StopForumSpam
5
+ * @author SleePy <sleepy @ simplemachines (dot) org>
6
+ * @copyright 2019
7
+ * @license 3-Clause BSD https://opensource.org/licenses/BSD-3-Clause
8
+ */
2 9
 
3 10
 // If we have found SSI.php and we are outside of SMF, then we are running standalone.
4 11
 if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
... ...
@@ -1,4 +1,11 @@
1 1
 <?php
2
+/**
3
+ * The Main class for Stop Forum Spam
4
+ * @package StopForumSpam
5
+ * @author SleePy <sleepy @ simplemachines (dot) org>
6
+ * @copyright 2019
7
+ * @license 3-Clause BSD https://opensource.org/licenses/BSD-3-Clause
8
+ */
2 9
 
3 10
 // If we have found SSI.php and we are outside of SMF, then we are running standalone.
4 11
 if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
5 12