Integrate SFS into the ContactForm
authorMarcel Werk <burntime@woltlab.com>
Tue, 20 Feb 2024 16:02:52 +0000 (17:02 +0100)
committerMarcel Werk <burntime@woltlab.com>
Tue, 20 Feb 2024 16:02:52 +0000 (17:02 +0100)
Closes #4584

wcfsetup/install/files/lib/data/blacklist/entry/BlacklistEntry.class.php
wcfsetup/install/files/lib/form/ContactForm.class.php

index bb840247e22d85a2bc3a93edc4c866baf3c3baac..aedc4aeedea530dee4e02ecfe92f105584f6708a 100644 (file)
@@ -35,7 +35,7 @@ class BlacklistEntry extends DatabaseObject
         }
 
         $conditions = new PreparedStatementConditionBuilder(true, 'OR');
-        if (BLACKLIST_SFS_USERNAME) {
+        if (BLACKLIST_SFS_USERNAME && $username !== '') {
             $conditions->add('(type = ? AND hash = ?)', ['username', self::getHash($username)]);
         }
         if (BLACKLIST_SFS_EMAIL_ADDRESS) {
index edd5c470d6f09e6ba95c6ed5ac0bf45a7715a117..a8c23f3cb1337bfabb027b8c1c41123fc8115ee8 100644 (file)
@@ -2,17 +2,20 @@
 
 namespace wcf\form;
 
+use wcf\data\blacklist\entry\BlacklistEntry;
 use wcf\data\contact\option\ContactOptionAction;
 use wcf\data\contact\recipient\ContactRecipientList;
 use wcf\system\attachment\AttachmentHandler;
 use wcf\system\email\Mailbox;
 use wcf\system\exception\IllegalLinkException;
+use wcf\system\exception\PermissionDeniedException;
 use wcf\system\exception\UserInputException;
 use wcf\system\option\ContactOptionHandler;
 use wcf\system\request\LinkHandler;
 use wcf\system\WCF;
 use wcf\util\HeaderUtil;
 use wcf\util\StringUtil;
+use wcf\util\UserUtil;
 
 /**
  * Customizable contact form with selectable recipients.
@@ -178,6 +181,17 @@ class ContactForm extends AbstractCaptchaForm
         if (!$this->privacyPolicyConfirmed) {
             throw new UserInputException('privacyPolicyConfirmed');
         }
+
+        if (BLACKLIST_SFS_ENABLE) {
+            $matches = BlacklistEntry::getMatches(
+                '',
+                $this->email,
+                UserUtil::getIpAddress()
+            );
+            if ($matches !== [] && BLACKLIST_SFS_ACTION === 'block') {
+                throw new PermissionDeniedException();
+            }
+        }
     }
 
     /**