{"id":46156420,"url":"https://github.com/delaneymethod/spamshield","last_synced_at":"2026-03-02T10:02:29.326Z","repository":{"id":318737962,"uuid":"1073771139","full_name":"delaneymethod/spamshield","owner":"delaneymethod","description":"Lightweight, pluggable spam scoring for PHP forms. Works with Craft, ExpressionEngine, Laravel, or vanilla PHP.","archived":false,"fork":false,"pushed_at":"2025-11-13T13:50:23.000Z","size":95,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-13T15:29:37.488Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/delaneymethod.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-10T15:38:59.000Z","updated_at":"2025-11-13T13:49:14.000Z","dependencies_parsed_at":"2025-10-21T17:15:15.224Z","dependency_job_id":"7102587a-aa21-43dc-a85b-4d19cfbe1f73","html_url":"https://github.com/delaneymethod/spamshield","commit_stats":null,"previous_names":["delaneymethod/spamshield"],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/delaneymethod/spamshield","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delaneymethod%2Fspamshield","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delaneymethod%2Fspamshield/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delaneymethod%2Fspamshield/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delaneymethod%2Fspamshield/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/delaneymethod","download_url":"https://codeload.github.com/delaneymethod/spamshield/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delaneymethod%2Fspamshield/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29998079,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-02T09:59:02.300Z","status":"ssl_error","status_checked_at":"2026-03-02T09:59:02.001Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-03-02T10:02:26.117Z","updated_at":"2026-03-02T10:02:28.937Z","avatar_url":"https://github.com/delaneymethod.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SpamShield\n\nLightweight, pluggable spam scoring for PHP forms. Works with Craft, ExpressionEngine, Laravel, or vanilla PHP.\n\n## Install\n\n```bash\ncomposer require delaneymethod/spamshield\n```\n\n## Usage\n\nCraft CMS with Freeform\n\n```php\nuse Craft;\nuse craft\\helpers\\Json;\nuse delaneymethod\\spamshield\\SpamShield;\nuse Solspace\\Freeform\\Events\\Forms\\ValidationEvent;\nuse Solspace\\Freeform\\Form\\Form;\nuse Solspace\\Freeform\\Freeform;\nuse Solspace\\Freeform\\Integrations\\Single\\FormMonitor\\Providers\\FormMonitorProvider;\nuse Solspace\\Freeform\\Library\\DataObjects\\SpamReason;\nuse yii\\base\\Event;\nuse yii\\log\\Logger;\n\nEvent::on(\n    Form::class,\n    Form::EVENT_BEFORE_VALIDATE,\n    static function (ValidationEvent $event) {\n        if (!$event-\u003eisValid) {\n            return;\n        }\n\n        $settingsService = Freeform::getInstance()-\u003esettings;\n        $settingsModel = $settingsService-\u003egetSettingsModel();\n        if ($settingsModel-\u003ebypassSpamCheckOnLoggedInUsers \u0026\u0026 Craft::$app-\u003egetUser()-\u003eid) {\n            return;\n        }\n\n        $form = $event-\u003egetForm();\n        if (!$form-\u003eisLastPage()) {\n            return;\n        }\n\n        $formMonitorProvider = Craft::$container-\u003eget(FormMonitorProvider::class);\n        if ($formMonitorProvider-\u003eisRequestFromFormMonitor($form)) {\n            return;\n        }\n\n        $submission = $form-\u003egetSubmission();\n\n        $handle = $form-\u003egetHandle();\n\n        $payload = $submission-\u003egetFormFieldValues();\n\n        $meta = [\n            'ip' =\u003e Craft::$app-\u003egetRequest()-\u003egetUserIP() ?? '',\n            'gibberish_word_minimum_length' =\u003e 6,\n            'check_dns_block_lists' =\u003e true,\n            'check_mx_record' =\u003e true,\n            'minimum_message_words' =\u003e 5,\n            'minimum_message_characters' =\u003e 300,\n        ];\n\n        $spamShield = new SpamShield();\n        $spamShield-\u003esetAllowedTerms(['ABB', 'KUKA']);\n        $spamShield-\u003esetDnsBlockLists(['zen.spamhaus.org', 'bl.spamcop.net']);\n\n        $result = $spamShield-\u003escore($payload, $meta);\n\n        if ($result['is_spam']) {\n            $form-\u003emarkAsSpam(\n                SpamReason::TYPE_GENERIC,\n                'SpamShield test failed',\n                Json::encode($result, JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT)\n            );\n        }\n    }\n);\n```\n\nVanilla PHP\n\n```php\nuse delaneymethod\\spamshield\\SpamShield;\n\n$meta = [\n    'ip' =\u003e $_SERVER['REMOTE_ADDR'] ?? '',\n    'gibberish_word_minimum_length' =\u003e 6,\n    'check_dns_block_lists' =\u003e true,\n    'check_mx_record' =\u003e true,\n    'minimum_message_words' =\u003e 5,\n    'minimum_message_characters' =\u003e 300,\n];\n\n$spamShield = new SpamShield();\n$spamShield-\u003esetAllowedTerms(['ABB', 'KUKA']);\n$spamShield-\u003esetDnsBlockLists(['zen.spamhaus.org', 'bl.spamcop.net']);\n\n$result = $spamShield-\u003escore($_POST, $meta);\nif ($result['is_spam']) {\n    // block or fake success\n}\n```\n\n### Tests\n\n```php\ncomposer install\ncomposer run fix\ncomposer run ci\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdelaneymethod%2Fspamshield","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdelaneymethod%2Fspamshield","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdelaneymethod%2Fspamshield/lists"}