Skip to content

Commit

Permalink
Block extra-US contact form submissions
Browse files Browse the repository at this point in the history
Toward #371.
  • Loading branch information
waldoj committed May 28, 2020
1 parent c9f45de commit 83b553d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions htdocs/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,23 @@ function show_form($form_data)
if (isset($_POST['form_data']))
{

/*
* Block non-US IPs. (This is where most spam comes from.)
*/
$url = 'http://ip-api.com/json/' . $_SERVER['REMOTE_ADDR'];
$json = get_content($url);
if ($json !== FALSE)
{
$ip_data = json_decode($json);
if ($ip_data !== FALSE)
{
if ($ip_data['countryCode'] != 'US')
{
die();
}
}
}

# Give spammers the boot.
if (!empty($form_data['zip']))
{
Expand Down

0 comments on commit 83b553d

Please sign in to comment.